% OBJECTIVE FUNCTION
f = @(x) -0.0001*(abs(sin(x(:,1)).*sin(x(:,2)).*exp(abs(100 - (x(:,1).^2 + x(:,2).^2).^0.5/pi))) + 1).^0.1

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

% GRAPHIC REPRESENTATION
[x,y] = meshgrid(o.lb:0.25: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 = [-1.3494 -1.3494 -2.06261]	% solution 
% info.animate = true	% plot animation 
% info.animfreq = 5	% frame frequency 
% info.np = 40	% number of points for meshgrid 
% optimview('fminsearch',info)