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

1 回表示 (過去 30 日間)
Ben Hischar
Ben Hischar 2021 年 8 月 15 日
編集済み: Image Analyst 2021 年 8 月 16 日
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
  1 件のコメント
Image Analyst
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 ExchangeMathematics and Optimization についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by