Using equation inside loop to and determining how much it has cooled over a period of time

1 次查看(过去 30 天)
Hi all
I am currently writing a script where i am measuring the cooling of a coke in a freezer.
I am using the a mnipulation of specific heat equation.
Ti+1 = Ti + K * delta(t) * (F-Ti)
Temp of coke is 20 degrees C
Temp of freezer is -2 degrees C
Ti +1 = cooling changes of substance
Ti = itnial temp of substance
K = conduction coeff
F = temp of freezer
consider K = 0.20 and delta(t) = 2
how can i work out the cooling of this over ( 200 number of minutes) and see the point where the bottle becomes less than 0 degrees C?
Should also display 'substance took ... minutes to reach 0 degrees C'
Thank you in advance, still trying to work this program out.

回答(1 个)

Image Analyst
Image Analyst 2021-8-15
You can either use a for loop
for t = 2 : 200
T(t) = T(t-1) + K * deltat * (F-T(t-1))
% Quit once it drops below 0
if T(t) < 0
break
end
end
Or use a while loop
maxIterations = 200
T(1) = initialTemperature
loopCounter = 1
while loopCounter < maxIterations && T(loopCounter) > 0
loopCounter = loopCounter + 1;
T(loopCounter) = .....whatever
end

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by