Clear Filters
Clear Filters

will fsolve/lsqnonlin and excel solver give the same solution to non linear least squares estimation?

3 views (last 30 days)
hi, i hope someone can clear my doubt.
I have a function S(x)= a1 exp(-exp[(x/b1)^g1]) + a2 exp(-cosh[(x/b2)^g2]). There is one constraint where a1<a2. I only have x values and S(x) values. Hence i have 6 unknown parameters to solve via non linear least squares estimation, minimising [S(x)-S(x_hat)]^2. I used Excel Solver to find an answer that converge when it is less than 1E-6. But in Matlab, what is the default where the iteration produces convergence? 1E-6? 1E-8? or something else? I have different values for the estimated parameters in both Excel and Matlab.
Thanks in advance for replying.;)

Answers (1)

Matthias Walle
Matthias Walle on 6 Oct 2016
You can use optimoptions function to set the step size tolerance and other performance characteristics to fsolve
For instance, your code might change to:
opts = optimoptions('fsolve', 'TolFun', 1E-8, 'TolX', 1E-8);
[B,fval] = fsolve(@(b) myfun(b,x,y), b0, opts);
you can use this to compare your results.
Hope this helped you,
Matthias

Community Treasure Hunt

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

Start Hunting!