Results 1 to 4 of 4

Math Help - While loops

  1. #1
    Newbie
    Joined
    May 2009
    Posts
    3

    While loops

    just wondering if anyone can help me

    i want to use a while loop to obtain values and use those values to plot onto a graph. My actual work is more complicated but ill give a simple example so i can understand it.

    clc
    x = 0;
    y = 1;


    while x < 10 && y < 11
    x = x + 1;
    y = y +1;
    end

    for this bit of code is there any way that i can store each individual value of and x and y?? and then use this to plot a graph???
    So basically the end output would be
    X = [1, 2, ....10]
    Y = [2, 3 .....11]
    Cheers
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Rhymes with Orange Chris L T521's Avatar
    Joined
    May 2008
    From
    Santa Cruz, CA
    Posts
    2,844
    Thanks
    3
    Quote Originally Posted by smallpat View Post
    just wondering if anyone can help me

    i want to use a while loop to obtain values and use those values to plot onto a graph. My actual work is more complicated but ill give a simple example so i can understand it.

    clc
    x = 0;
    y = 1;


    while x < 10 && y < 11
    x = x + 1;
    y = y +1;
    end

    for this bit of code is there any way that i can store each individual value of and x and y?? and then use this to plot a graph???
    So basically the end output would be
    X = [1, 2, ....10]
    Y = [2, 3 .....11]
    Cheers
    What you want to do is create an empty array (for both x and y) and in the while loop, store the values as elements in their corresponding arrays. What language are you programming this in??
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    May 2009
    Posts
    3
    im using matlab, can u show me exactly with the above example??
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Rhymes with Orange Chris L T521's Avatar
    Joined
    May 2008
    From
    Santa Cruz, CA
    Posts
    2,844
    Thanks
    3
    Quote Originally Posted by smallpat View Post
    im using matlab, can u show me exactly with the above example??
    I'm not an expert at matlab (I'm more of the Maple guy.. XD), but if you do a google search on this stuff, you'll find pages like this.

    I hope this helps.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Need help with Matlab (Loops)
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 8th 2011, 12:50 AM
  2. matlab for loops?
    Posted in the Math Software Forum
    Replies: 5
    Last Post: February 28th 2010, 09:49 PM
  3. Multiplication loops?
    Posted in the Math Software Forum
    Replies: 2
    Last Post: July 13th 2009, 07:24 AM
  4. how many loops in a coil
    Posted in the Math Topics Forum
    Replies: 2
    Last Post: February 20th 2008, 10:09 AM
  5. While Loops! Help me please!!!!
    Posted in the Discrete Math Forum
    Replies: 3
    Last Post: October 8th 2007, 01:25 PM

Search Tags


/mathhelpforum @mathhelpforum