# What does the argument 'TolFun' indicate in function 'fit'?

36 views (last 30 days)
Shuangfeng Jiang on 11 Nov 2020
Answered: Deepak Meena on 21 Mar 2021
I would like to use the fucntion 'fit' to fit my data with the model, and there's the option called 'TolFun' which should be set when adopting the method of nonlinear Least Squares (Details in the help page: https://www.mathworks.com/help/curvefit/fit.html#d122e31414 ).
I know the name 'TolFun' may be a legacy, and it may correspond to 'OptimalityTolerance' or 'FunctionTolerance'. If it corresponds to the latter, is it a relative bound as mentioned in the help page https://www.mathworks.com/help/optim/ug/tolerances-and-stopping-criteria.html ?
If so, how to choose an appropriate value for it geneally when doing curve fitting?
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Deepak Meena on 21 Mar 2021
Hi,
TolFun is a lower bound on the change in the value of the objective function during a step. If |f(xi) – f(xi+1)| < TolFun, the iterations end. Solvers generally use TolFun as a relative bound, meaning iterations end when |f(xi) – f(xi+1)| < TolFun(1 + |f(xi)|), or a similar relative measure.
Coming to your question how to choose an appropriate value for it geneally when doing curve fitting , TolFun is not compulsory argument while using the fit function . Be default it takes value of 10^-6 . Try fitting the curve with the default value and See what are your results
Thanks
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Categories

Find more on Linear and Nonlinear Regression in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by