I'm having trouble plotting the temperature field for a thin plate with border temperatures known.

조회 수: 10(최근 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.

답변(2개)

Torsten
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)

William Rose
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.

범주

Find more on Mathematics and Optimization 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!

Translated by