I'm having trouble plotting the temperature field for a thin plate with border temperatures known.
2 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone, i'm having trouble plotting the temperature distribution for a 2d heat transfer in a thin plate, with border temperatures known. I have to plot the distribution from the equation in the figure. For now I'm using the following code, but It doesn't seem to be working.
X = 5;
Y = 5;
L = 1;
W =1;
theta1 = zeros(X,Y);
for n =1:100
theta1 = theta1 + (2/pi)*(((-1)^(n+1)+1)/(n))*sin(n*pi*X1/L).*(sinh(n*pi*Y1/L))./(sinh(n*pi*W/L));
end
surf(X,Y,theta1)
X and Y being the number of nodes.
0 件のコメント
採用された回答
William Rose
2022 年 8 月 14 日
theta1 has dimensions 5x5.
You define it with a loop over n=1:100. SInce there is no index in the assignment statement, you are assigning a value to all of theta1 on each loop pass. YOu need to do something like
for i=1:5
for j=1:5
theta1(i,j)=sin(i/2)+cos(j)/2; %or whatever
end
end
Then you must plot it:
surf(1:5,1:5,theta1); %or similar
Try somehting like that.
0 件のコメント
その他の回答 (1 件)
Torsten
2022 年 8 月 15 日
編集済み: Torsten
2022 年 8 月 15 日
Write a function
function T = Temp(x,y)
T = ...;
end
in which you calculate the value of the infinite sum for x-y coordinates (x,y) and call and plot the function like
x = 0:0.1:1;
y = 0:0.1:1.5;
[X,Y] = ndgrid(x,y);
for i = 1:numel(x)
for j = 1:numel(y)
T(i,j) = Temp(x(i),y(j));
end
end
surf(X,Y,T)
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!