Indexing into a matrix to create a plot

1 view (last 30 days)
Justin Hayes
Justin Hayes on 29 Mar 2020
Commented: Justin Hayes on 30 Mar 2020
I would like to store Tskin for all t values and then use indexing to create a plot. How do I accomplish this?
Tambient = 20; % C
Tfilm = (T + Tambient)/2;
T = 29;
for t = 1:1:10
k_air_2 = 0 * (2.4131 + 0.0078 * T) * 10^-2; % W/m*C = 0
k_cotton = 0; % because long sleeve
rho_air = 1.2893 - 0.004 * Tfilm; % kg/m^3
mu_air = (0.0047 * Tfilm + 1.7164) * 10^-5; % kg/m*s
k_air_ambient= (2.4131 + 0.0078 * Tfilm) * 10^-2; % W/m*C
Re = Diameter_forearm * V * rho_air / mu_air;
h_air = (k_air_ambient/Diameter_forearm) * (0.3 + ((0.62 * Re.^.5 * Pr.^.333)/((1 + (0.4 * Pr)^.667).^.25))*(1 + ((Re/282000).^(5/8))).^.8) % J/s*K*m^2
Uskin = (k_air_2/thickness_air) + (k_cotton/thickness_shirt) + (h_air) % J/s*K*m^2
Uambient = (k_air_ambient/thickness_air) + (k_cotton/thickness_shirt) + (h_air)
old_Tskin = T
Tskin = [(T * Area * Cp_air * rho_air)/(t-(t-1)) + Qgen + (Uambient * Area * Tambient)]/((Area * Cp_air * rho_air / ((t-(t-1)))) + Uskin * Area);
T = Tskin
Tfilm = (T + Tambient)/2;
fprintf('Your frontal forearm temperature is %.2f C after %d seconds ' ,Tskin,t)
dT = old_Tskin - Tskin
if dT > 0.007
display('Your forearm probably feels cold')
elseif dT < -0.005
display('Your forearm probably is probably feeling hot')
else
display ('Your forearm feels comfortable')
end
end
  2 Comments
Justin Hayes
Justin Hayes on 30 Mar 2020
T = 29; % %C
% Constants
Area = .1/2; % m^2 divide by 2 for the "frontal area", I assume this is 50% of the SA of arm
Qgen = 4.5/2; %J/s divide by 2 for the "frontal area"
thickness_shirt = 0.002286; % m
thickness_air = 0.01 % m thickness of air layer in shirt
k_cotton = 0.04; % W/m*C
Diameter_forearm = 0.07; % m
Tambient = 20; % C
% Properties of ambient air
Pr = 0.71;
V = 5; %m/s
Cp_air = 1006; %J/kg*K
Tfilm = (T + Tambient)/2;
p = input('long-sleeve, short-sleeve, tank, or none: ','s')
for t = 1:1:100
k_air_2 = 0 * (2.4131 + 0.0078 * T) * 10^-2; % W/m*C = 0
k_cotton = 0;
rho_air = 1.2893 - 0.004 * Tfilm; % kg/m^3
mu_air = (0.0047 * Tfilm + 1.7164) * 10^-5; % kg/m*s
k_air_ambient= (2.4131 + 0.0078 * Tfilm) * 10^-2; % W/m*C
Re = Diameter_forearm * V * rho_air / mu_air;
h_air = (k_air_ambient/Diameter_forearm) .* (0.3 + ((0.62 * Re.^.5 * Pr.^.333)/((1 + (0.4 * Pr).^.667).^.25)).*(1 + ((Re/282000).^(5/8))).^.8) % J/s*K*m^2
Uskin = (k_air_2/thickness_air) + (k_cotton/thickness_shirt) + (h_air) % J/s*K*m^2
Uambient = (k_air_ambient/thickness_air) + (k_cotton/thickness_shirt) + (h_air)
Tskin = [(T * Area * Cp_air * rho_air)/(t-(t-1)) + Qgen + (Uambient * Area * Tambient)]/((Area * Cp_air * rho_air / ((t-(t-1)))) + Uskin * Area);
T = Tskin
Tfilm = (T + Tambient)/2
end

Sign in to comment.

Answers (1)

MaryD
MaryD on 29 Mar 2020
you can just try
T_skin(t)= [(T * Area * Cp_air * rho_air)/(t-(t-1)) + Qgen + (Uambient * Area * Tambient)]/((Area * Cp_air * rho_air / ((t-(t-1)))) + Uskin * Area);
inside the loop.
then outside the loop
t=1:1:10
plot(t,T_skin)
  1 Comment
Justin Hayes
Justin Hayes on 30 Mar 2020
When I use this method to plot it produces an empty plot

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by