%% Create Nondefault Options
% Set options for fminsearch to use a plot function and a stricter stopping condition than the default.

options = optimset('PlotFcns','optimplotfval','TolX',1e-7);

% Minimize Rosenbrock's function starting from the point (–1,2), and monitor the minimization process by using the options. Rosenbrock's function has a minimum value of 0 at the point (1,1).

fun = @(x)100*((x(2) - x(1)^2)^2) + (1 - x(1))^2; % Rosenbrock's function
x0 = [-1,2];
[x,fval] = fminsearch(fun,x0,options)

% Copyright 2018 The MathWorks, Inc.