% OBJECTIVE FUNCTION
f = @(x) (1+((x(:,1) + x(:,2) + 1).^2).*(19 - 14*x(:,1) + ...
       3*x(:,1).^2 - 14*x(:,2) + 6*x(:,1).*x(:,2) + ...
       3*x(:,2).^2)).*(30 + ((2*x(:,1) - 3*x(:,2)).^2).* (18 - 32*x(:,1)+ ...
       12*x(:,1).^2 + 48*x(:,2) - 36*x(:,1).*x(:,2) + 27*x(:,2).^2))

% OPTIMIZATION SETTINGS
o = struct	% initializing struct
o.d = 2	% dimension of decision variable
o.lb = -2	% lower bounds
o.ub = 2	% upper bounds

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

% OPTIMIZATION 
rng(0)	% for tractability 
[xmin,fmin,popPos,popCost] = ga(f,o)	% running minimization  

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