2D Temperature distribution from 1D temperature distribution T(x)

3 views (last 30 days)
Hello all,
Hope everyone is doing good.
I have got 1D temperature distribution T(x) along axial distance. Based on a convention below, I need to extract 2D temperature distribution based on 1D. The convention is based on the figure attached here.
In my hand, I have data related to x-position and 1D temperature distribution + convention data to extract 2D temperature distribution.
% Position along x-direction
x_position = [0.05; 0.0625; 0.075; 0.0875; 0.10; 0.1125; 0.125; 0.1375; 0.15; 0.1625; 0.175; 0.1875; 0.2; 0.2125; 0.225; 0.2375; 0.25; 0.2625; 0.2750; 0.2875; 0.3];
% 1D temperature
desired_temperatures = [100; 100; 55.39; 30.383; 23.047; 20.894; 20.26; 20.077; 20.023; 20.007; 20.002; 20; 20; 20; 20; 20; 20; 20; 20; 20; 20];
% Introduced y-distance for 2D
y = [0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 4.0 4.2 4.4 4.6 4.8 5.0]; % j //26 points
% 2D temperature distribution
if 0 < y < 0.25 - x
Theta(x, y) = T(0.25 y);
else if 5 > y > 4.75 +x
Theta(x, y) = T(y - 4.75);
else
Theta(x, y) = T(x);
end
end
Lets say, when T(0.25 - y) returns T(0.25), MATLAB couldn't understand/return the variable from T(0.25) because I believe the temperature variable are stored in indices as, T(1) T(2) T(3) T(4) .... so so on.
So how to make Matlab understand the above (if) - (else if) loops works ?
Can someone share your ideas on above context ?
Thank you

Accepted Answer

Torsten
Torsten on 27 Sep 2022
x_position = [0.05; 0.0625; 0.075; 0.0875; 0.10; 0.1125; 0.125; 0.1375; 0.15; 0.1625; 0.175; 0.1875; 0.2; 0.2125; 0.225; 0.2375; 0.25; 0.2625; 0.2750; 0.2875; 0.3];
% 1D temperature
desired_temperatures = [100; 100; 55.39; 30.383; 23.047; 20.894; 20.26; 20.077; 20.023; 20.007; 20.002; 20; 20; 20; 20; 20; 20; 20; 20; 20; 20];
% Introduced y-distance for 2D
y = [0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 4.0 4.2 4.4 4.6 4.8 5.0]; % j //26 points
f = @(xq) interp1(x_position,desired_temperatures,xq);
[X,Y] = ndgrid(x_position,y);
for i = 1:numel(x_position)
for j = 1:numel(y)
THETA(i,j) = T(x_position(i),y(j),f);
end
end
contourf(X,Y,THETA)
colorbar
function Theta = T(x,y,f)
if 0 < y && y < 0.25 - x
Theta = f(0.25-y);
elseif 5 > y && y> 4.75 + x
Theta = f(y-4.75);
else
Theta = f(x);
end
end
  3 Comments
Torsten
Torsten on 27 Sep 2022
Edited: Torsten on 27 Sep 2022
However, I couldn't able to understand the function (Theta = T(x,y,f)) for 2D temperature distribution. Could you please explain it ?
What exactly don't you understand in the function ? It's in principle a copy of your code :
if 0 < y < 0.25 - x
Theta(x, y) = T(0.25 y);
else if 5 > y > 4.75 +x
Theta(x, y) = T(y - 4.75);
else
Theta(x, y) = T(x);
end
The function f is an interpolating function that returns an approximation for desired_temperatures(x) if x is not in the list of the x_positions.

Sign in to comment.

More Answers (0)

Categories

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