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

Réponses (1)

Walter Roberson
Walter Roberson le 13 Mai 2011

1 vote

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 commentaires

mouna
mouna le 13 Mai 2011
yes; thank you very much
bym
bym le 13 Mai 2011
you might also "accept" the answer
mouna
mouna le 17 Mai 2011
good morning,
for example in this same equation how i can plot 3 slabs (y1,y2,y3) in the same graph??
Robert Cumming
Robert Cumming le 17 Mai 2011
hold on
Jan
Jan le 17 Mai 2011
plot(y1); hold('on'); plot(y2); plot(y3)
Walter Roberson
Walter Roberson le 17 Mai 2011
Or,
plot(x,y1,x,y2,x,y3)

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Tags

Question posée :

le 13 Mai 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by