using least square fit to find the best fit parameters

I have 3 variables y, x1, and x2 stored in vector form. I know that y=f(x1,x2) and has the form y = a*b*x1/(1+b*x1+c*x2) + d*x1. a,b,c, and d are parameters. How can I use lsqnonlin to find a,b,c,d?
Thank you

5 Comments

What have you tried so far?
I got this
y=....;
x1=.....;
x2=.....;
fun=@(x) (y-x(1)*x(2)*x1/(1+x(2)*x1+x(3)*x2)-x(4)*x1);
x0=[0.00001,0.00001,0.1,0.00001];
x=lsqnonlin(fun,x0);
a=x(1);
b=x(2);
c=x(3);
d=x(4);
But the fit does not fit really well with the data, so I don't know if I did anything wrong.
A low quality fit can have two reasons, either the algorithm failed or the data is too noisy. I don't know how sensitive lsqnonlin is to initial values, but it is possible you ended up with a local minimum.
is there any other way that I can find the parameters?
You could try with a different fitting function or with different initial guesses. Those two will only help if your function properly describes the trend in your data and if your data isn't noisy in the first place.

Sign in to comment.

Answers (1)

Hi, Annie, upload your data file please, if possible.

Tags

Asked:

on 26 Feb 2020

Answered:

on 26 Feb 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!