Mathematics

Setting Minimization Options

You can specify control options that set some minimization parameters using an `options` structure that you create using the function `optimset`. You then pass `options` as in input to the optimization function, for example, by calling `fminbnd` with the syntax

• ```x = fminbnd(fun,x1,x2,options)
```

or `fminsearch` with the syntax

• ```x = fminsearch(fun,x0,options)
```

Use `optimset` to set the values of the `options` structure. For example, to set the `'Display'` option to `'iter'`, in order to display output from the algorithm at each iteration, enter

• ```options = optimset('Display','iter');
```

`fminbnd` and `fminsearch` use only the `options` parameters shown in the following table.

 `options.Display` A flag that determines if intermediate steps in the minimization appear on the screen. If set to `'iter'`, intermediate steps are displayed; if set to `'off'`, no intermediate solutions are displayed, if set to `final,` displays just the final output. `options.TolX` The termination tolerance for x. Its default value is `1.e-4`. `options.TolFun` The termination tolerance for the function value. The default value is `1.e-4`. This parameter is used by `fminsearch`, but not `fminbnd`. `options.MaxIter` Maximum number of iterations allowed. `options.MaxFunEvals` The maximum number of function evaluations allowed. The default value is `500` for `fminbnd` and `200*length(x0)` for `fminsearch`.

The number of function evaluations, the number of iterations, and the algorithm are returned in the structure `output` when you provide `fminbnd` or `fminsearch` with a fourth output argument, as in

• ```[x,fval,exitflag,output] = fminbnd(@humps,0.3,1);
```

or

• ```[x,fval,exitflag,output] = fminsearch(@three_var,v);
```

 Fitting a Curve to Data Output Functions