% OBJECTIVE FUNCTION
f = @(x) sin(10*pi*x)./(2*x) + (x-1).^4

% OPTIMIZATION SETTINGS
o = struct	% initializing struct
o.d = 1	% dimension of decision variable
o.lb = 0.5	% lower bounds
o.ub = 2.5	% upper bounds

% GRAPHIC REPRESENTATION
x = o.lb:0.01:o.ub
plot(x, f(x))

% ALGORITHM OPTIONS

o.maxit = 10	% number of iterations 

% 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.5485634  -0.8690]	% solution 
% info.animate = true	% plot animation 
% info.np = 300	% number of points for meshgrid 
% optimview('ga',info)