오리진 Nonlinear Fitting - olijin Nonlinear Fitting

오리진 Nonlinear Fitting - olijin Nonlinear Fitting

Good afternoon, I'm posting this question because I'm not able to find a satisfactory result of a non-linear fit with Matlab. On the contrary, OriginLab returns a good fit together with errors for fit parameters. Here my x and y data: x = [177600,961200, 2504000, 4997000, 8884000]; y = [6.754, 24.416, 58.622, 107.980, 154.507]; yErr = sqrt(y);

The fitting function is the following: y = V + (A-V)*S*x*EXP(-S*x) where V, A and S are the parameters which I need to calculate from the fit. OriginLab gives me the following:

  • V = 1.978 ± 0.889
  • A = 585 ± 64
  • S = 4.392E-8 ± 6.771E-9

On Matlab I tried all the possible form of non-linear regression: fitnlm, lsqcurvefit, nlinfit etc... every time the same warning:The Jacobian is ill conditioned. Here is an example:

Nonlinear regression model:

y ~ a1 + (a2 - a1)*a3*x*exp( - a3*x)

Estimated Coefficients:

Estimate SEtStatpValue

__________ _______________________________

a1 -0.67892.9104e-19-2.3327e+182.0265e-73

a2 530.788.0894e-206.5614e+213.2371e-87

a3 5.2511e-08 5.1865e-10101.255.7063e-08

Of course such small standard errors are not reliable, but still I'm not able to reproduce the Origin results. Any suggestions?

Accepted Answer

오리진 Nonlinear Fitting - olijin Nonlinear Fitting

Edited: Matt J on 14 Sep 2018

Well, I guess I would credit OriginLab with knowing how to pre-scale the x,y data appropriately. If you do this manually, then lsqcurvefit works fine, and gives a slightly better fit (according to resnorm) than OriginLab,

c=10*max(x);

a0=[1.9780 ,585, 4.3920e-08*c];

F=@(a,x) a(1)+(a(2)-a(1)).*a(3).*x/c.*exp(-a(3).*x/c);

[a,resnorm,~,~,~,~,J]=lsqcurvefit(F,[1,100,1],x,y,[],[],...

optimoptions('lsqcurvefit','Display','iter'));

solution=[a(1), a(2), a(3)/c]

resnorm

condJ = cond(full(J))

plot(x,y,'x',x,F(a,x),'--'); xlabel 'x', xlabel 'y';

오리진 Nonlinear Fitting - olijin Nonlinear Fitting

More Answers (2)

오리진 Nonlinear Fitting - olijin Nonlinear Fitting

Another frustrating scenario.. simple polynomial fit y = a+bx+cx^2 I get another error on Matlab "Polynomial is badly conditioned". On the other hand Origin does it better.. why? To me this is really embarrassing.


오리진 Nonlinear Fitting - olijin Nonlinear Fitting

The global solution looks like below:

Root of Mean Square Error (RMSE): 1.42818042380826

Sum of Squared Residual: 10.1984966147457

Correlation Coef. (R): 0.999655170571204

R-Square: 0.999310460049744

Adjusted R-Square: 0.998620920099487

Determination Coef. (DC): 0.999310460049744

Chi-Square: 0.212210508410738

F-Statistic: 1449.24229503583

Parameter Best Estimate

---------- -------------

v 0.665211685653936

a 544.888484613983

s 4.9628897712431E-8

See Also

Categories

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.