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!