% OBJECTIVE FUNCTION
f = @(x) (x(:,1) - 13 + ((5 - x(:,2)).*x(:,2) - 2).*x(:,2)).^2 + ...
   (x(:,1) - 29 + (( x(:,2) + 1).*x(:,2) - 14).*x(:,2)).^2 

% OPTIMIZATION SETTINGS
o = struct	% initializing struct
o.lb = -10	% lower bounds
o.ub = 12	% upper bounds

% GRAPHIC REPRESENTATION
[x,y] = meshgrid(o.lb:0.8:o.ub)
surf(x,y,f([x(:),y(:)]))

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

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