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.
mandbfrom the answers:hold on,plot(tm,(9.4157*tm)./(3.4418+tm),'r');and at least just eyeballing it, I'd suggest your solution is closer to fitting. - David_G