Mathematics |
Converting Your Optimization Code to MATLAB Version 5 Syntax
Most of the function names and calling sequences changed in Version 5 to accommodate new functionality and to clarify the roles of the input and output variables.
This table lists the optimization functions provided by MATLAB and indicates the functions whose names have changed in Version 5.
Old (Version 4) Name |
New (Version 5) Name |
fmin |
fminbnd |
fmins |
fminsearch |
foptions |
optimget, optimset |
fzero |
fzero (name unchanged) |
|
lsqnonneg |
optimset
and optimget
functions.
In addition to the information in this section, consult the individual function reference pages for information about the new functions and about the arguments they take.
Using optimset and optimget
The optimset
function replaces foptions
for overriding default parameter settings. optimset
creates an options
structure that contains parameters used in the optimization routines. If, on the first call to an optimization routine, the options
structure is not provided, or is empty, a set of default parameters is generated. See the optimset
reference page for details.
New Calling Sequences
Version 5 of MATLAB makes these changes in the calling sequences:
options
structure to adjust parameters to the optimization functions (see optimset
, optimget
).
'final'
as the default, the new default is options.display = 'notify'
).
exitflag
that describes the termination state.
output
structure that contains information about the problem solution relevant to that function.
The sections below describe how to convert from the old function names and calling sequences to the new ones. The calls shown are the most general cases, involving all possible input and output arguments. Note that many of these arguments are optional. See the function reference pages for more information.
Converting from fmin to fminbnd. In Version 4, you used this call to fmin
.
In Version 5, you call fminbnd
like this.
Converting from fmins to fminsearch. In Version 4, you used this call to fmins
.
In Version 5, you call fminsearch
like this.
Converting to the new form of fzero. In Version 4, you used this call to fzero
.
In Version 5, replace the TRACE
and TOL
arguments with
if TRACE == 0, val = 'none'; elseif TRACE == 1 val = 'iter'; end OPTIONS = optimset('Display',val,'TolX',TOL);
Now call fzero
like this.
Converting from nnls to lsqnonneg. In Version 4, you used this call to nnls
.
In Version 5, replace the tol
argument with
Now call lsqnonneg
like this.
Troubleshooting | Numerical Integration (Quadrature) |