Hi, I'm trying to plot the summation graph of y=1/(1+x)^2, so far my code is
x=[-10:10]
y=zeros(size(x))
for n=1:21
for k=1:11
terms= k.*(-x(n)).^(k-1)
y=y+terms
end
end
at the moment it is plotting a straight line but my friend believes this code is correct, any help is greatly appreciated.

 Respuesta aceptada

Star Strider
Star Strider el 24 de En. de 2019

0 votos

I’m not certain what a ‘summation graph’ is.
One of these will probably do what you want:
x = -10:10;
y = zeros(size(x));
for n=1:21
for k=1:11
terms(n,k) = k.*(-x(n)).^(k-1);
end
end
row_cumsum = cumsum(terms);
col_cumsum = cumsum(terms,2);
row_sum = sum(terms);
col_sum = sum(terms,2);
figure
plot(row_cumsum)
figure
plot(col_cumsum)
figure
plot(row_sum)
figure
plot(col_sum)
Experiment to get the result you want.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 24 de En. de 2019

Respondida:

el 24 de En. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by