필터 지우기
필터 지우기

I am trying to plot the temperature over time

조회 수: 7 (최근 30일)
Ashley Turner
Ashley Turner 2019년 4월 25일
댓글: Ashley Turner 2019년 4월 25일
clear;clc;
time_step = 1;
volume = 0.5;
density = 1;
heat_capacity = 4184;
T_init = 20;
T_working = 0;
T_desired = 10;
t_final = 300;
convection_coefficient = 10;
surface_area = 2*pi*((0.0635/2)^2+0.2032*0.0635/2);
%%
bottle_capacity = volume*density*heat_capacity;
T_bottle = T_init;
bottle_heat = bottle_capacity*(T_bottle-T_working);
for t = 0:time_step:t_final
heat_loss = convection_coefficient*time_step*(T_bottle-T_working);
bottle_heat = bottle_heat-heat_loss;
T_bottle = bottle_heat/bottle_capacity+T_working
if T_bottle < T_desired
t
break
end
end
  댓글 수: 3
Ashley Turner
Ashley Turner 2019년 4월 25일
so start the for loop after i delcare time? I'm really not the best at coding. where do I place the plot command?
Image Analyst
Image Analyst 2019년 4월 25일
There is a plot command below in Jan's answer. Did you overlook it?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2019년 4월 25일
tVector = 0:time_step:t_final
for it = 1:numel(tVector)
heat_loss = convection_coefficient*time_step*(T_bottle-T_working);
bottle_heat = bottle_heat-heat_loss;
T_bottle = bottle_heat/bottle_capacity+T_working
Temperature(it) = T_bottle;
if T_bottle < T_desired
t
break
end
end
n = numel(Temperature);
plot(tVector(1:n), Temperarure)
  댓글 수: 2
Ashley Turner
Ashley Turner 2019년 4월 25일
Im getting an error from the last line.
Ashley Turner
Ashley Turner 2019년 4월 25일
Nevermind. Thank you! I think I got it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Pulse and Transition Metrics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by