function h=xplot(x,ip)
%   Plot funtion to use with optimization algorithms.
%
%   h=xplot(x,ip)
%
%   x: current point
%   ip: (0) initialization (save initial point), 
%       (>0) plot figure ip with pause, (<0) plot figure ip
%   h: plot handle

%   Copyright (c) 2001 by LASIM-DEQUI-UFRGS
%   $Revision: 1.0 $  $Date: 2001/07/12 20:10:10 $
%   Argimiro R. Secchi (arge@enq.ufrgs.br)

global X_PLOT
persistent xo

if ~ip,
  h=plot(x(1),x(2),'ro');
  xo=x;
  X_PLOT=0;
elseif X_PLOT,
  h=plot([x(1) xo(1)],[x(2) xo(2)],'r');
  if ip > 0,
    disp('Pause: hit any key to continue...'); pause;
  end
  xo=x;
else
  h=0;
end
