Consider the data of Example C.2.5. Determine the best-fit value of the coefficient b in the square-root function
f=b h^{1 / 2} (1)
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} (2)
Referring to Example C.1.3, whose model is y = bx^m, we see here that y = f , h = x, and m = 0.5. From Equation (1) of Example C.1.3,
b=\frac{\sum_{i=1}^n h_i^{0.5} y_i}{\sum_{i=1}^n h_i} (3)
The MATLAB program to carry out these calculations is shown next.
% Enter the data.
h = (1:11);
time = [26, 19, 14, 12, 11, 9.5, 9, 8.5, 8, 7.5, 7];
% Compute flow rate from (2).
flow = 250./time;
% Compute b from (3).
b = sum(sqrt(h).*flow)/sum(h)
% Compute f from (1).
f = b*sqrt(h);
% Compute J, S, and r squared.
J = sum((f - flow).^2)
S = sum((flow - mean(flow)).^2)
r2 = 1 - J/S
The result is a = 10.4604 and the flow model is f = 10.4604 \sqrt{h}. The quality-of-fit values are J = 5.5495, S = 698.2203, and r² = 0.9921, which indicates a very good fit.