Results 1 to 5 of 5

Math Help - Matlab help

  1. #1
    Newbie
    Joined
    Sep 2008
    Posts
    2

    Exclamation Matlab help

    Hey, im new to programing in matlab and am having a really hard time with it so far. Im stuck on this one problem:

    Define vector xi=(i-m)/(m+3); i=1,...,(2m-1) using a single loop

    could someone help me out here. im not even really sure how to start this.
    I know how to do simple loops like
    for i=1:1:5
    x=x+8
    end

    but thats as far as my skills go right now.
    Any help would be awesome
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by george View Post
    Hey, im new to programing in matlab and am having a really hard time with it so far. Im stuck on this one problem:

    Define vector xi=(i-m)/(m+3); i=1,...,(2m-1) using a single loop

    could someone help me out here. im not even really sure how to start this.
    I know how to do simple loops like
    for i=1:1:5
    x=x+8
    end

    but thats as far as my skills go right now.
    Any help would be awesome

    i posted this in the programing section too, so feel free to delete that one.
    With one loop:

    Code:
    m=10;
    xi=zeros(1,2*m-1);
    
    for idx=1:2*m-1;
      xi(idx)=(idx-m)/(m-3);
    end
    With zero loops

    Code:
    m=10;
    xi=([1:2*m-1]-m)/(m-3);
    RonL
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Senior Member bkarpuz's Avatar
    Joined
    Sep 2008
    From
    R
    Posts
    481
    Thanks
    2
    Quote Originally Posted by george View Post
    Hey, im new to programing in matlab and am having a really hard time with it so far. Im stuck on this one problem:

    Define vector xi=(i-m)/(m+3); i=1,...,(2m-1) using a single loop

    could someone help me out here. im not even really sure how to start this.
    I know how to do simple loops like
    for i=1:1:5
    x=x+8
    end

    but thats as far as my skills go right now.
    Any help would be awesome

    i posted this in the programing section too, so feel free to delete that one.
    I have the following code, which may help you to learn the idea.

    Code:
    s=100;
    k=3;
    for n=1:(k+1)
        x(n)=1;
    end;
    for n=(k+1):(s-1)
        mn=mod(n,12);
        if mn==0
            p=-1;
        elseif mn<=3
            p=0;
        else
            p=245/1000;
        end;
        x(n+1)=x(n)-p*x(n-k);
    end;
    n=1:s
    plot(n,x(n),'-rs','LineWidth',1,'MarkerEdgeColor','b','MarkerSize',2)
    %n=1:(s-1)
    %plot(x(n),x(n+1),'-rs','LineWidth',1,'MarkerEdgeColor','b','MarkerSize',2)
    grid on;
    It's better you ask stuff like this to http://www.mathhelpforum.com/math-he...uter-software/
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Sep 2008
    Posts
    2
    can someone explain to me what "idx" means?
    thanks

    never mind. "idx" is just a variable i think
    but could some one help me understand what the code is doing?

    haha.. never mind. i understand it. Im learning, just very slowly.
    Last edited by george; September 20th 2008 at 01:17 PM.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Senior Member bkarpuz's Avatar
    Joined
    Sep 2008
    From
    R
    Posts
    481
    Thanks
    2

    Exclamation

    Quote Originally Posted by george View Post
    can someone explain to me what "idx" means?
    thanks

    never mind. "idx" is just a variable i think
    but could some one help me understand what the code is doing?

    haha.. never mind. i understand it. Im learning, just very slowly.
    idx is the name of the counter that runs from 1 to 2*m-1 1 by 1.

    a very helpful website for the questions is MATLAB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2010, 02:59 AM
  2. Matlab FFT Help
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 3rd 2009, 12:48 PM
  3. help about ODE in matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 31st 2009, 03:10 AM
  4. Matlab Please help me
    Posted in the Math Software Forum
    Replies: 8
    Last Post: November 10th 2008, 04:40 PM
  5. Matlab
    Posted in the Calculus Forum
    Replies: 3
    Last Post: August 20th 2008, 10:39 PM

Search Tags


/mathhelpforum @mathhelpforum