This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the 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',...

    Note:   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'}.

    Note:   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.

More About

Was this topic helpful?