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.
0 个评论
回答(1 个)
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
1 个评论
Image Analyst
2021-8-16
编辑:Image Analyst
2021-8-16
Ben, did my hints work for you? I have not heard back from you yet.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!