I am trying to plot the temperature over time
Show older comments
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 Comments
KALYAN ACHARJYA
on 25 Apr 2019
time=0:time_step:t_final;
for i=1:1:length(time)+1
% do here
end
Try to indexing temp(i) and plot with respect to time, ensure that both having same length.
It may look like: temp(i) canculation w.r.t different time.
Ashley Turner
on 25 Apr 2019
Image Analyst
on 25 Apr 2019
There is a plot command below in Jan's answer. Did you overlook it?
Answers (1)
Jan
on 25 Apr 2019
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)
Categories
Find more on Data Distribution Plots 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!