Consider again Example 1.4.1. Water in a glass measuring cup was allowed to cool after being heated to 204°F. The ambient air temperature was 70°F. The measured water temperature at various times is given in the following table.
Obtain a functional description of the water temperature versus time.
600 | 480 | 360 | 240 | 120 | 0 | Time (sec) |
153 | 160 | 169 | 178 | 191 | 204 | Temperature (°F) |
1200 | 1080 | 960 | 840 | 720 | Time (sec) |
127 | 132 | 137 | 141 | 147 | Temperature (°F) |
From Example 1.4.1, we learned that the relative temperature, ΔT = T − 70 has the exponential form
ΔT = be^{mt} (1)
We can find values of m and b by using \boxed{p = polyfit(x,log(y),1)}. The first element p_1 of the vector \boxed{p} will be m, and the second element p_2 will be ln b. We can find b from b = e^{p_2} .
The following MATLAB program performs the calculations.
% Enter the data.
time = (0:120:1200);
temp = [204,191,178,169,160,153,147,141,137,132,127];
% Compute the relative temperature and its logarithm.
rel_temp = temp - 70;
log_rel_temp = log(rel_temp);
% Fit a first-degree polynomial.
p = polyfit(time,log_rel_temp,1);
% Compute m and b from the polynomial coefficients.
m = p(1),b = exp(p(2))
% Compute DT (delta T) from (1).
DT = b*exp(m*time);
% Compute J, S, and r squared.
J = sum((DT-rel_temp).^2)
S = sum((rel_temp - mean(rel_temp)).^2)
r2 = 1 - J/S
The results are m = −6.9710 × 10^{−4} and b = 1.2916 × 10^2, and the corresponding function is
\Delta T=b e^{m t} \quad \text { or } \quad T=\Delta T+70=b e^{m t}+70
The quality-of-fit values are J = 47.4850, S = 6.2429 × 10³, and r² = 0.9924, which indicates a very good fit.