Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan 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',...
    'Algorithm','sqp','Display','iter','ConstraintTolerance',1e-12);

    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?