-1
$\begingroup$

So, I have this matlab problem, and I'm totally lost. Below, you will find my attempt. We are supposed to fit a polynomial curve to the data, but I'm a bit confused as to how the to get a polynomial to match the known relationship. I've got polyfit solving for the form of y = 1 / (ax + b), but I don't know where to go from there. Any help would be greatly appreciated.

problem

x= 5:5:50;
y= [15 25 32 33 37 35 38 39 41 42];
p= polyfit(x,1 ./ y,1)
a= p(1);
b= p(2);

xFit= 5:50;
yFit= xFit ./ (a * xFit + b)
semilogy(x,y,'o',xFit,yFit,'-');

$\endgroup$
1
  • 1
    $\begingroup$ aside from this being homework, this type of question belongs on stackoverflow $\endgroup$ Commented Mar 16, 2017 at 17:49

1 Answer 1

3
$\begingroup$

The trick to this one is at the end there. You took the reciprocal of your y data but what you need is the reciprocal of the entire equation.

Original: $y = a\frac{x}{b+x}$

Reciprocal: $\frac{1}{y}=\frac{1}{a}\frac{b+x}{x}$

So, when you simplify that a little, you'll get: $y^{-1}=\frac{b}{a}x^{-1}+\frac{1}{a}$

Hopefully, you can see that this is a linear equation but your variables are the reciprocals of x and y. So, when you get over to MATLAB, make the same vectors you did, but then get the reciprocals of those. Use polyfit() on those reciprocals and you'll get coefficients for $\frac{b}{a}$ and $\frac{1}{a}$. Solve those for $a$ and $b$ and check your work; you'll see a fit!

$\endgroup$
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.