plot y(i)
显示 更早的评论
[EDIT: 20110513 13:39 CDT - reformat - WDR]
hi,
i have this sum:
for i=2:200
y=y+i;
how i can use plot to trace y=f(i)
thanks in advance
回答(1 个)
Walter Roberson
2011-5-13
y = cumsum(2:200);
plot(y)
Or, using the for loop
x = 2:200;
numx = length(x);
y = zeros(numx,1);
ty = 0;
for i = 1:numx
ty = ty + x(i);
y(i) = ty;
end
plot(y)
6 个评论
mouna
2011-5-13
bym
2011-5-13
you might also "accept" the answer
mouna
2011-5-17
Robert Cumming
2011-5-17
hold on
Jan
2011-5-17
plot(y1); hold('on'); plot(y2); plot(y3)
Walter Roberson
2011-5-17
Or,
plot(x,y1,x,y2,x,y3)
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!