resetoptions

Syntax

options2 = resetoptions(options,optionname)
options2 = resetoptions(options,multioptions)

Description

example

options2 = resetoptions(options,optionname) resets the specified option back to its default value.

Tip

If you want only one set of options, use options as the output argument instead of options2.

example

options2 = resetoptions(options,multioptions) resets multiple options back to their default values.

Examples

collapse all

Create options with some nondefault settings. Examine the MaxIterations setting.

options = optimoptions('fmincon','Algorithm','sqp','MaxIterations',2e4,...
    'SpecifyObjectiveGradient',true);
options.MaxIterations
ans =

       20000

Reset the MaxIterations option to its default value.

options2 = resetoptions(options,'MaxIterations');
options2.MaxIterations
ans =

   400

The default value of the MaxIterations option is 400 for the 'sqp' algorithm.

Create options with some nondefault settings. Examine the MaxIterations setting.

options = optimoptions('fmincon','Algorithm','sqp','MaxIterations',2e4,...
    'SpecifyObjectiveGradient',true);
options.MaxIterations
ans =

       20000

Reset the MaxIterations and Algorithm options to their default values. Examine the MaxIterations setting.

multiopts = {'MaxIterations','Algorithm'};
options2 = resetoptions(options,multiopts);
options2.MaxIterations
ans =

        1000

The default value of the MaxIterations option is 1000 for the default 'interior-point' algorithm.

Input Arguments

collapse all

Optimization options, specified as an object as created by optimoptions.

Example: optimoptions('fmincon','Algorithm','sqp','SpecifyObjectiveGradient',true)

Option names, specified as a name in single quote marks. The allowable option names for each solver are listed in the options section of the function reference page.

Example: 'Algorithm'

Data Types: char

Multiple options, specified as a cell array of names.

Example: {'Algorithm','OptimalityTolerance'}

Data Types: cell

Output Arguments

collapse all

Optimization options, returned as an object as created by optimoptions.

Introduced in R2016a