optimget
Reads one option from an options struct created by optimset.
Category: Mathematics > Optimization
Syntax
val = optimget(options, 'name')
Returns the value of option name, or [] if it is not set.
val = optimget(options, 'name', default)
Returns default when the option is empty or missing.
Description
Solvers such as fzero and fminsearch call optimget to read their settings, so that an unset option falls back to the solver's own default. Calling it yourself is useful to check what a struct contains or to build your own function with the same option style.
Input arguments
options- Struct made by
optimset. 'name'- Option name, such as
'TolX'or'MaxIter'. Matching ignores letter case. default- Value to use when the option holds
[].
Output arguments
val- The option value, or the default.
Example
Reading with and without defaults
o = optimset('MaxIter', 50);
optimget(o, 'MaxIter')
optimget(o, 'TolX', 1e-6)
isempty(optimget(o, 'TolX'))
Output
ans = 50
ans = 1.0000e-06
ans = logical
1