Main Content

Set and Change Options

The recommended way to set options is to use theoptimoptionsfunction. For example, the following code sets thefminconalgorithm tosqp, specifies iterative display, and sets a small value for theConstraintTolerancetolerance.

options = optimoptions('fmincon',...'Algorithm','sqp','Display','iter','ConstraintTolerance',1e-12);

Note

Useoptimsetinstead ofoptimoptionsfor thefminbnd,fminsearch,fzero, andlsqnonnegsolvers. These are the solvers that do not require an Optimization Toolbox™ license.

You can change options in several ways. For example, you can use dot notation.

options.StepTolerance = 1e-10;

Or, you can change options usingoptimoptions.

options = optimoptions(options,'StepTolerance',1e-10);

Note

Ensure that you passoptionsin your solver call, as shown in this example.

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

To reset an option to its default value, useresetoptions.

options = resetoptions(options,'StepTolerance');

Reset more than one option at a time by passing a cell array of option names.

options = resetoptions(options,{'Algorithm','StepTolerance'});

You can also set and change options using theOptimizeLive Editor task.

See Also

||

Related Topics