Indexing into a matrix to create a plot
이전 댓글 표시
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
Ameer Hamza
2020년 3월 29일
Several variables in your code are not defined. Please specify the values of all variables.
Justin Hayes
2020년 3월 30일
답변 (1개)
MaryD
2020년 3월 29일
0 개 추천
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)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!