MATLAB Answers

Sum of the series with two variable

112 views (last 30 days)
Kemal Bey
Kemal Bey on 19 Apr 2021 at 17:48
Commented: Kemal Bey on 20 Apr 2021 at 6:24
Given that
x=0:0.01:1;
t=0:0.001:0.1;
n is from 1 to 20 (not infinity)
How to make plot(x,u)? Please help!!!
  2 Comments
Kemal Bey
Kemal Bey on 19 Apr 2021 at 18:14
x = 0:0.01:1;
t = 0:(2/100):2;
u=zeros(1,numel(t));
for n= 1:20
u=u-((4/(pi.^3)).*((-1).^(n)-1).*exp(-(n.^2).*(pi.^2).*(t/10)).*sin(n.*pi.*x))/n.^2;
end
plot(x,u,'b')
That is my code. I should get parabolic (symmetric) distribution of heat over a rod. But I obtained something that is not symmetric paraboloid. If you replace t with t = 0:(2/100):2, it will become noticeable

Sign in to comment.

Accepted Answer

David Hill
David Hill on 19 Apr 2021 at 19:17
Edited: David Hill on 20 Apr 2021 at 0:11
[x,t]=meshgrid(0:.01:1,0:.001:.1);
u=zeros(size(x));
for n=1:100
u=u+((-1)^n-1)/(n^2)*exp(-n^2*pi^2*t/10).*sin(n*pi*x);
end
u=u*4/(pi)^3;
surf(x,t,u);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by