how to select proper parameters for "opt.StartPoint" ?

6 views (last 30 days)
I want to fit some data as below code:
if true
p=fittype('a+k*b/(b+x)','independent','x');
opt=fitoptions(p);
opt.StartPoint=[1e-8,0.5,1e-8];
f=fit(x,y,p,opt)
Y=f(x);
corrcoef(y,Y)
end
when I delete the code "opt=fitoptions(p);opt.StartPoint=[1e-8,0.5,1e-8];", I get the value of "a", "b", and "k" as below:
General model:
f(x) = a+k*b/(b+x)
Coefficients:
a = 6.611e-08
b = 0.4854
k = 5.829e-08
then I add the code "opt=fitoptions(p);opt.StartPoint=[1e-8,0.5,1e-8];", and then I get the values as below:
General model:
f(x) = a+k*b/(b+x)
Coefficients:
a = 1e-08
b = 0.5
k = 1e-08
I don't know why "a","b" and "k" never change? and how shall I set "opt.StartPoint" properly?
thank you!

Answers (1)

Matt J
Matt J on 22 Sep 2014
Edited: Matt J on 22 Sep 2014
It's possible the solution is simply unstable because you have bad data. For example, if all your y-data are very close to zero (as compared to x), then clearly any solution with a and b*k close to zero will give a reasonable fit.
If it is a matter of the initial guess, though, you might be able to generate a better one by re-arranging the model equation in linear form. In other words, starting with the model equation,
y=a +b*k/(x+b)
re-arrange as,
a*x -b*y + a*b + b*k =x.*y
and re-parametrize this as
A*x + B*y + C =x.*y
Solve the linear equations for [A;B;C],
ABC = [x(:),y(:), ones(length(x),1)]\[x(:).*y(:)];
A=ABC(1);
B=ABC(2);
C=ABC(3);
a=A;
b=-B;
k=(C-a*b)/b;
Now, use this preliminary solution as a start point for the fit,
opt.StartPoint=[a,b,k];

Community Treasure Hunt

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

Start Hunting!