温度随着时间的推移而下降

时间:2016-02-01 11:52:41

标签: matlab while-loop temperature

我是MATLAB的新手,正在学习如何使用while循环。我在使用while循环来解决我需要计算油箱温度的问题时遇到了麻烦。坦克从200度开始,我需要知道它需要多少天,直到它降到45以下,到目前为止我只能让MATLAB运行程序一次,它停在168度。如果有人能提供帮助,我将不胜感激。

% This program will calculate the # of days it will take for the...
... temperature in the tank to drop below 45 degrees celsius
clc
clear
A = 60; %Surface area of the tank in m^2
t = 86400; %Number of seconds in a day 
Cp = 4980; %The heat capacity of the liquid in  J/(kg*°C)
Tair = 23; %Average temperature surrounding the tank in °C 
To = 200; %Average ethylene glycol temperature on day 0 in °C 
h = 9.2; %The heat transfer coefficient in W/(m2*°C)
m = 35000; %The mass of liquid in the tank in kg
n = 0; %The day
Tn=0
while (Tn < 45)
    Tn =((1-((h*A*t)/(m*Cp))^n)*To+Tair);
    n=n+1;
end
Tn
n

1 个答案:

答案 0 :(得分:0)

假设你的公式是正确的,这应该可以完成你的工作:

Tn=200;
while (Tn >= 45)
    Tn =((1-((h*A*t)/(m*Cp))^n)*To+Tair);
    n=n+1;
end

它肯定会第一次进入while循环,然后只要温度超过45新温度再计算一天。但也许您的配方也存在问题?