% Exa = 1;

switch Exa
case 1
  % minimum of single function
  p = 2;
  xMin = fminbnd(@(x)sin(p*x),2,3)
  xMin/pi
  xMin = fminsearch(@(x)sin(p*x),2.5)/pi

%  options.TolX=1e-7; % Octave only
%  xMin = fminsearch(@(x)sin(p*x),2.5,options)/pi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 2
  % maximum of a function of 2 variables
  [xx,yy] = meshgrid( [-1:0.1:4],[-2:0.1:2]);

  f = @(x,y)-2*x.^2 -3*x.*y-2*y.^2 + 5*x+2*y;

  surfc(xx,yy,f(xx,yy)); xlabel('x'); ylabel('y');
  xMin = fminsearch(@(x)-f(x(1),x(2)),[1.5,0])
end%switch
