Incorrect lsqcurvefit fitting, stays in initial guess

4 views (last 30 days)
hg song
hg song on 24 Jun 2022
Commented: hg song on 26 Jun 2022
hello all,
I am trying to fitting the data with the following function:
y = a*exp(-x/b)+c*exp(-x/d) , where a,b,c,d are 4 free parameters.
a range from (1e9,5e10), b range from (0,100) ,c range from (5e8,5e9), d range from (100,500);
x range from (1e-5, 1.2e-3)
Saying b = 20, the (-x*1e6/b) could range vastly.
After applied the method in my code, it barely improved the performance.
Here are the codes:
xdata =[2.00E-05 2.45E-05 3.00E-05 3.70E-05 4.55E-05 5.55E-05 6.75E-05 8.25E-05 1.01E-04 ...
1.24E-04 1.51E-04 1.85E-04 2.26E-04 2.76E-04 3.37E-04 4.12E-04 5.03E-04 6.15E-04 7.52E-04 9.19E-04 1.12E-03];
ydata =[2.51E+10 1.68E+10 1.24E+10 8.10E+09 6.33E+09 4.73E+09 3.28E+09 1.88E+09 1.26E+09 ...
7.77E+08 5.17E+08 3.45E+08 2.34E+08 1.57E+08 9.70E+07 5.35E+07 2.94E+07 1.53E+07 7.77E+06 3.89E+06 1.82E+06];
a0=[5; 1; 2; 1.5];
options = optimset('TolFun',1e-28);
lb = [0 ; 0; 1; 1];
ub = [10;10;10;10];
fun=@(x,xdata)(x(1)*1e10)*exp(-xdata*1e6/x(3)/10)+(x(2)*1e9)*exp(-xdata*1e6/x(4)/100);
for i = 1:100
x = lsqcurvefit(fun,a0,xdata,ydata,lb,ub,options);
a0 = x;
end
Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance. Local minimum possible. lsqcurvefit stopped because the size of the current step is less than the value of the step size tolerance.
semilogy(xdata,fun(x,xdata),xdata,ydata,'+');
And the best fit could be (5.5e10, 26, 1e9, 160)
Is there anybody with a suggestion for improvement?
Best wishes
  3 Comments
hg song
hg song on 25 Jun 2022
Dear Torsten,
I've tried the method, unfortunately, the performance is less satisfactory.
I found it is better if the xdata & ydata is piecewisely fitted, same as the "fminspleas" suggests.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 25 Jun 2022
xdata =[2.00E-05 2.45E-05 3.00E-05 3.70E-05 4.55E-05 5.55E-05 6.75E-05 8.25E-05 1.01E-04 ...
1.24E-04 1.51E-04 1.85E-04 2.26E-04 2.76E-04 3.37E-04 4.12E-04 5.03E-04 6.15E-04 7.52E-04 9.19E-04 1.12E-03];
ydata =[2.51E+10 1.68E+10 1.24E+10 8.10E+09 6.33E+09 4.73E+09 3.28E+09 1.88E+09 1.26E+09 ...
7.77E+08 5.17E+08 3.45E+08 2.34E+08 1.57E+08 9.70E+07 5.35E+07 2.94E+07 1.53E+07 7.77E+06 3.89E+06 1.82E+06];
xdata=xdata*1e5;
ydata=ydata/1e10;
funlist={@(bd,xd) exp(-bd(1)*xd), @(bd,xd) exp(-bd(2)*xd)};
lb=[1/100,1/500];
ub=[inf,1/100];
[bd,ac]=fminspleas(funlist,[1,10],xdata,ydata,lb,ub,1./ydata);
a=ac(1); c=ac(2);
b=1./bd(1); d=1./bd(2);
fun=@(x) a*exp(-x/b)+c*exp(-x/d);
x=linspace(min(xdata),max(xdata));
plot(x,fun(x),xdata,ydata,'+');
  1 Comment
hg song
hg song on 26 Jun 2022
Dear Matt,
Thanks for your reply. It looks well in linear axis.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!