Plotting values from while loop results
16 次查看(过去 30 天)
显示 更早的评论
Hi, anyone knows how do i store the values for b in vector form, so that i can plot a graph using the values of b.
a=0
while a<100
b= 2*a
a= a+1
end
0 个评论
回答(2 个)
Image Analyst
2012-11-27
a=0
while a<100
b(a+1) = 2*a;
a = a+1;
end
plot(b);
or even better (to get the "a" axis correct so you'll have b=0 at a=0 instead of at 1):
a = 0 : 99;
b = 2 * a;
plot(a, b, 'ro-');
grid on;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!