PLOT from summing series.

Good night guys. I have the following problem above:
A = 1;
e = 1;
y = 2.5*10^-3;
Tmol = 40;
TiNJ = 250;
for t = 0:20
S = 0;
for n = 0:10000
x1 = (-1)^n/((n+1/2)*pi);
x2 = exp((-(n + 1/2)^2)*pi^2*A*t/e^2);
x3 = cos((n + 1/2)*pi*y/e);
S = S + x1*x2*x3;
end
Tyt = Tmol - 2*S*(Tmol - TiNJ);
[Tyt,t]
end
To sum up, this little code will generates 20 points (Tyt,t pairs), i want a plot for that.
I could plot manually doing plot(x1,y1,x2,y2...) but how i plot automatically when the program ends the 20 points?

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 2 de Sept. de 2011

0 votos

You need to store your data in a vector:
Before your 'for t=0:20' line, insert a line: 'Tyt=zeros(21,1);' Change the assignment of Tyt to be 'Tyt(t+1)=Tmol - 2*S*(Tmol - TiNJ);'.
At the end, plot(0:20,Tyt); or plot(Tyt,0:20); depending on your need.

Categorías

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

Etiquetas

Preguntada:

el 2 de Sept. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by