I'm having trouble plotting the temperature field for a thin plate with border temperatures known.
1 次查看(过去 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!