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 件のコメント

Shaun Hamilton
Shaun Hamilton 2019 年 10 月 12 日
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.
jlvdoorn
jlvdoorn 2019 年 10 月 12 日
symsum is defined as
symsum(function, variable, lower boundry, upper boundry)
It is a summation from n=1 to n=Inf over the function mentioned above.

サインインしてコメントする。

 採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 10 月 12 日

1 投票

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 件のコメント

jlvdoorn
jlvdoorn 2019 年 10 月 12 日
Thnx!
@Sulaymon Eshkabilov it is working now!
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 10 月 12 日
You're welcome! It is a pleasure.
jlvdoorn
jlvdoorn 2019 年 10 月 12 日
Thnx, Now I am having a new (somewhat same) problem.
I need to plot this function at t = 0.1 and x = 0.5, y=0:0.1:1. alpha = 1e-4.
Could you please help me again?
Many thnx!!
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 10 月 13 日
Hi,
This exercise is pretty much the same as the previous on, e.g.:
x = 0.5;
h = 0.1;
ymax = 2;
y = 0:h:ymax; T(1,:)=ones(size(y));
for n=1:5-1
for m = 1:numel(y)
T(n+1,m) = T(n,m)+(48/(pi^6))*sum(((-1^n)/(n^3))*((-1^m)-1)/(m^3))*...;
end
end
Good luck.
jlvdoorn
jlvdoorn 2019 年 10 月 13 日
Thanks for your answer, unfortunately it is not working :(
It gives me a 5 x 21 matrix for T. But I expected an array of length: numel(y).
Could you please help me one last time?
clear
clc
a = 1e-4;
t = 0.1;
x = 0.5;
h = 0.1;
ymax = 2;
y = 0:h:ymax;
T(1,:)=ones(size(y));
for n=1:5-1
for m = 1:numel(y)
T(n+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
end
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 10 月 13 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by