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 TolCon 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.TolX = 1e-10;
  • optimoptions. For example,

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

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.

Was this topic helpful?