%% Copy Options to Another Solver
% Transfer nondefault options for the fmincon solver to options for the fminunc solver.
% Set options for fmincon to use the sqp algorithm and at most 1500 iterations.

oldoptions = optimoptions(@fmincon,'Algorithm','sqp','MaxIterations',1500)

%
% Transfer the applicable options to the fminunc solver.

options = optimoptions(@fminunc,oldoptions)

% The algorithm option does not transfer to fminunc because 'sqp' is not a valid algorithm option for fminunc.
% Copyright 2012 The MathWorks, Inc.