The documentation on the stopping criteria has always been vague. Basically, though, TolX triggers a stop when the change in x is too small, TolFun triggers a stop when the change in the function value is too small or the gradient magnitude gets sufficiently small. How the thresholds are derived from the values of TolFun and TolX is not documented consistently and varies among different solvers that use these parameters. Stopping will also occur if the number of function evaluations (MaxFunEvals) or the number of iterations (MaxIter) exceeds the values of those parameters.
You can add your own stopping criterion using the OutputFcn option. You write the Output Function to return a 'stop' flag when your criterion is met.
Best Answer