# Trying to plot a temperature distribution and generate a temperature contourn!

56 views (last 30 days)
Lucas Resende on 15 Aug 2022
Commented: Torsten on 15 Aug 2022
Good night t all! I'm trying to plot the temperature distribution of a problem of 2 dimensional heat transfer on a thin plate, where the four borders have known temperature. The plate have L = 1m and W = 1m. I'm not allowed to use finite differences, so I have to plot a temperature contourn from the following temperature distribution equation
But I am lost. This is the code I've being using so far, but the graph I have generate looks nothing like a temperature distribution. I'm using a plate with 25 nodes. I need help!
X = 5;
Y = 5;
theta1 = zeros (X,Y);
for n =1:100
for X1 = 1:X
for Y1 = 1:Y
theta1(X1,Y1)=(2/pi)*(((-1)^(n+1)+1)/(n))*sin(n*pi*X1/L)*(sinh(n*pi*Y1/L))/(sinh(n*pi*W/L));
end
end
end
theta1sum = sum(theta1);
surf(1:5,1:5,theta1)
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Akira Agata on 15 Aug 2022
How about the following?
L = 1;
W = 1;
[xGrid, yGrid] = meshgrid(0:0.025:1, 0:0.025:1);
T = zeros(size(xGrid));
for n = 1:100
T = T + (((-1)^(n+1)+1)/n).*sin(n*pi*xGrid/L).*...
(sinh(n*pi*yGrid/L)./sinh(n*pi*W/L));
end
T = T*(2/pi);
figure
surf(xGrid, yGrid, T)
xlabel("X", "FontSize", 12)
ylabel("Y", "FontSize", 12)
zlabel("T", "FontSize", 12)
##### 1 CommentShowHide None
Torsten on 15 Aug 2022
@Lucas Resende comment moved here:
It worked perfectly! Thank you very much!

Sign in to comment.

### Categories

Find more on Mathematics in Help Center and File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!