Plotting Sum of series
37 views (last 30 days)
Show older comments
jlvdoorn
on 12 Oct 2019
Commented: Sulaymon Eshkabilov
on 13 Oct 2019
Hi all,
I want to plot the tempersature distribution:
For x = 0.5 (constant) and y =0:0.1:2;
I used the code below which give me an error:
Error using plot
Data must be numeric, datetime, duration or an array convertible to double.
What am I doing wrong?
Thnx
Jan
clear
clc
x = 0.5;
h = 0.1;
ymax = 2;
y = 0:h:ymax;
syms n
T = 273+symsum(400/sinh(2*pi*n)*n*pi*(1-((-1)^n)*cos(1))/((1-(n^2)*(pi^2))^2)*sin(n*pi*x)*sinh(n*pi*y), n, 1, Inf);
plot(T,y);
xlegend("Static Temperature (c)");
ylegend("Position (m)");
2 Comments
Shaun Hamilton
on 12 Oct 2019
If you look at the output of T, you can see why you are not getting a plot. I would, plot each of the four answers for T.
Accepted Answer
Sulaymon Eshkabilov
on 12 Oct 2019
Hi,
In your exercise, it is more appropriate to use numerical solution approach instead of symbolic math. Here is one of the possibe solutions:
x = 0.5;
h = 0.1;
ymax = 2;
y = 0:h:ymax; T(1,:)=273*ones(size(y));
for n=1:5-1
for m = 1:numel(y)
T(n+1,m) = T(n,m)+sum(400/sinh(2*pi*n)*n*pi*(1-((-1)^n)*cos(1))/((1-(n^2)*(pi^2))^2)*sin(n*pi*x)*sinh(n*pi*y(m)));
end
end
%%
plot(y, T);
xlabel("Static Temperature (c)");
ylabel("Position (m)");
Good luck.
6 Comments
Sulaymon Eshkabilov
on 13 Oct 2019
Hi
From your question, I see that you'd like to set n = 1. If so, the loop will be:
T(1,:)=ones(size(y)); n=1;
for m = 1:numel(y)
T(1,m) = T(n,m)+(48/(pi^6))*sum(((-1^n)/(n^3))*((-1^m)-1)/(m^3))*sin(n*pi*x)*sin(m*pi*y(m))*exp(-(n^2+m^2)*pi^2*a*t);
end
Good luck.
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!