Reputation: 153
I'm working on curve-fitting data which consists of two arrays:
t: 1, 3, 4, 7, 8, 10
P: 2.1, 4.6, 5.4, 6.1, 6.4, 6.6
The relationship between the two variables is given by P = mt/(b+t)
. I'm told to determine the constants m and b by curve-fitting the equation to the data points. This should be done by writing the reciprocal of the equation and using a first-order polynomial. Here is my code:
t = [1 3 4 7 8 10];
P = [2.1 4.6 5.4 6.1 6.4 6.6];
p = polyfit(t, t./P, 1);
m = 1/p(1)
b = p(2)*m
tm = 1:0.01:10;
Pm = (m*tm)./(b+tm);
plot(t,P, 'o', tm, Pm)
The answer in the book is m = 9.4157
and b = 3.4418
. The code above yields m = 8.4807
and b = 2.6723
. What is my mistake? Any suggestions would be greatly appreciated. Thank you for your time.
Upvotes: 3
Views: 6243
Reputation: 2447
To follow up on the comment made by @David_G, it looks like you have a better answer. In fact, if you run the data through Curve Fitting Toolbox in MATLAB you get:
General model:
f(t) = m*t/(b+t)
Coefficients (with 95% confidence bounds):
b = 2.587 (1.645, 3.528)
m = 8.448 (7.453, 9.443)
Goodness of fit:
SSE: 0.1594
R-square: 0.9888
Adjusted R-square: 0.986
RMSE: 0.1996
Your solution is almost as good:
Goodness of fit:
SSE: 0.1685
R-square: 0.9881
Adjusted R-square: 0.9852
RMSE: 0.2053
And both of them are better than the one in the book:
Goodness of fit:
SSE: 0.404
R-square: 0.9716
Adjusted R-square: 0.9645
RMSE: 0.3178
Upvotes: 1