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?
回答(1 个)
Fangjun Jiang
2011-9-2
0 个投票
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.
类别
在 帮助中心 和 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!