Plotting Temperature profile as a function of x,y and z.

7 Ansichten (letzte 30 Tage)
Nihal Acharya
Nihal Acharya am 25 Jun. 2018
Kommentiert: Nihal Acharya am 28 Jun. 2018
Hello,
I have a temperature function, which is a function of all 3 co-ordinates x,y and z. It is just one equation which iterates in for loops. But I am unable to plot this temperature function in 3D space.
I would really appreciate some help with the plotting aspect. I don't know how exactly to use isosurface or slicing even though I went through a couple of questions posted here.
Thanks in advance!
%Properties of the system
eta = 0.5;
P = 200;
v = 0.1;
k = 42.7;
d = 0.0038;
rho = 7850;
Cp = 477;
T0 = 300;
fileID = fopen('myfile.txt','w');
Q=eta*P/v;
alpha = k/Cp;
for t = 1:1:100
for x = 1:1:10
for y = 1:1:10
for z = 1:1:10
psi = x - v*t;
R = sqrt(psi^2 + y^2 + z^2);
T(:) = (Q/(2*pi*k*d))*exp(-v*psi/(2*alpha))*exp(-(v*R)/(2*alpha))/R + T0;
fprintf('%f\n', T)
fprintf(fileID,'%d\t%d\t%d\t%f\n',x,y,z,T);
end % z loop end
fprintf(fileID,'\n');
end % y loop end
fprintf(fileID,'\n');
end % x loop end
fprintf(fileID,'\n');
end % t loop end

Akzeptierte Antwort

Boris Blagov
Boris Blagov am 25 Jun. 2018
Bearbeitet: Boris Blagov am 25 Jun. 2018
I think you have many more dimensions than three - you have five dimensions. x,y,z,t and the values (temperature)
You have one T for each (x,y,z) triple and you have hundred triples for t = 1:100.
For example, you have one temperature associated with x=1, y=1 (conditional on z and t), another temperature associated with x = 2 and y = 1 (conditional on z and t) and so forth. You can generate a 3-D plot, conditioning on two of the four variables, i.e. for the temperature as a function of all "x" and all "y", conditional on one z and one t.
Here is the code for that (just for a single t!). Consider preallocating T for speed. I have changed the line T(:) from your code to T(x,y,z) and fixed t = 1.
%Properties of the system
clc
clear
eta = 0.5;
P = 200;
v = 0.1;
k = 42.7;
d = 0.0038;
rho = 7850;
Cp = 477;
T0 = 300;
fileID = fopen('myfile.txt','w');
Q=eta*P/v;
alpha = k/Cp;
% for t = 1:1:100
t = 1;
for x = 1:1:10
for y = 1:1:10
for z = 1:1:10
psi = x - v*t;
R = sqrt(psi^2 + y^2 + z^2);
T(x,y,z) = (Q/(2*pi*k*d))*exp(-v*psi/(2*alpha))*exp(-(v*R)/(2*alpha))/R + T0;
end % z loop end
end % y loop end
end % x loop end
% end % t loop end
surf(T(:,:,1))
Edit: consider using "fclose at the end" as a general good practice
  6 Kommentare
Walter Roberson
Walter Roberson am 27 Jun. 2018
isosurface() several representative T values, getting "shells" of equal temperature in 3 space.
Nihal Acharya
Nihal Acharya am 28 Jun. 2018
Hi Walter, Is the use of isosurface() here something similar to the following attached post? -
https://in.mathworks.com/matlabcentral/answers/110977-3d-density-plot-multiple-isosurfaces-on-the-same-plot
Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by