This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Set and Change Options

The recommended way to set options is to use the optimoptions function. For example, to set the fmincon algorithm to sqp, set iterative display, and set a small value of the ConstraintTolerance tolerance:

options = optimoptions('fmincon',...


Use optimset instead of optimoptions for the fminbnd, fminsearch, fzero, and lsqnonneg solvers. These are the solvers that do not require an Optimization Toolbox™ license.

Change options as follows:

  • Dot notation. For example,

    options.StepTolerance = 1e-10;
  • optimoptions. For example,

    options = optimoptions(options,'StepTolerance',1e-10);
  • Reset an option to default using resetoptions. For example,

    options = resetoptions(options,'StepTolerance');

    Reset more than one option at a time by passing a cell array of option names, such as {'Algorithm','StepTolerance'}.


Ensure that you pass options in your solver call. For example,

[x,fval] = fmincon(@objfun,x0,[],[],[],[],lb,ub,@nonlcon,options);

You can also set and change options using the Optimization App.

Related Topics