% OBJECTIVE FUNCTION
f = @(x) 100*(x(:,2) - x(:,1).^2).^2 + (x(:,1) - 1).^2

% GRAPHIC REPRESENTATION
[x,y] = meshgrid(-2:0.5:2, -1:0.5:2.5)
surf(x,y,f([x(:),y(:)]))

% OPTIMIZATION 
rng(0)	% for tractability 
x0 = [-1.2,1]	% initial guess 
[xmin,fmin,info] = fminsearch(f,x0)	% running minimization  

% ANIMATION
% Uncomment the following code to generate animation % 
% rng(0)
% x0 = [-1.2,1]
% [~,~,info] = fminsearch(f,x0)
% info.sol = [1 1 0]	% solution 
% info.animate = true	% plot animation 
% info.animfreq = 5	% frame frequency 
% optimview('fminsearch',info)