MATLAB: How to use TolFun to stop iteration when resnorm less than it

lsqnonlintolfun

Hi,
I am using lsqcurvefit to do parameter estimation. I do not need to have a very small resnorm at the end. So if the resnorm is already less than my tolerance, it is more than enough for me.
So, e.g., I set TolFun to 1e-2:
optionsLSQ = optimset('Display','Iter','TolFun',1e-2);
[ki,resnorm] = lsqcurvefit(@funObj,ki,tdata,xdata,lb,[],optionsLSQ);
And this is what I get:
Norm of First-order
Iteration Func-count f(x) step optimality CG-iterations
0 3 0.113218 0.311
1 6 0.00709841 0.237501 0.0365 0
2 9 0.00463864 0.0462264 0.00193 0
Optimization terminated: first-order optimality less than OPTIONS.TolFun,
and no negative/zero curvature detected in trust region model.
As you can see, at iteration 1, f(x)<0.01, and yet the iteration does not stop. What should I do to make it stop right after f(x)<TolFun?
Thank you in advance.

Best Answer

Have a look at Tolerances and Stopping Criteria in the documentation.
HTH,
Arnaud
Related Question