Consider again Example 1.4.2. A hole 6 mm in diameter was made in a translucent milk container (Figure 1.4.7). A series of marks 1 cm apart was made above the hole. While adjusting the tap flow to keep the water height constant, the time for the outflow to fill a 250 ml cup was measured (1 ml = 10^{−6} m³). This was repeated for several heights. The data are given in the following table.
Obtain a functional description of the volume outflow rate f as a function of water height h above the hole.
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Height h (cm) |
26 | 19 | 14 | 12 | 11 | 9.5 | 9 | 8.5 | 8 | 7.5 | 7 | Time t (s) |
First obtain the flow rate data in ml/s by dividing the 250 ml volume by the time to fill:
f=\frac{250}{t} (1)
In Example 1.4.2, we learned that the following power function can describe the data:
f=b h^m (2)
We can find the values of m and b by using \boxed{p = polyfit (log10 (x), log10 (y), 1)}. The first element p_1 of the vector \boxed{p} will be m, and the second element p_2 will be log b. We can find b from b = 10^{p_2} . The following MATLAB program performs the calculations.
% Enter the data.
h = (1:11);
time = [26, 19, 14, 12, 11, 9.5, 9, 8.5, 8, 7.5, 7];
% Compute the flow rate from (1) and its logarithm.
flow = 250./time;
logflow = log10(flow);logheight = log10(h);
% Fit a first-degree polynomial.
p = polyfit(logheight,logflow, 1);
% Compute m and b from the polynomial coefficients.
m = p(1),b = 10^p(2)
% Compute f from (2).
f = b*h.^m;
% Compute J, S, and r squared.
J = sum((f - flow).^2)
S = sum((flow - mean(flow)).^2)
r2 = 1 - J/S
The results are m = 0.5499 and b = 9.4956, and the corresponding function is
f=b h^m=9.4956 h^{0.5499}
The quality-of-fit values are J = 2.5011, S = 698.2203, and r² = 0.9964, which indicates a very good fit.