1. ## 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

2. Originally Posted by smallpat
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??

3. im using matlab, can u show me exactly with the above example??

4. Originally Posted by smallpat
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.