function visual(fun,Lb,Ub,level,np,nolabel)
//   2-D visualization of function fun
//
//   visual(fun,Lb,Ub,level,np,nolabel)
//
//   Lb, Ub: lower and upper bound vectors to plot
//   level: number of contour curves or values of the contours
//   np: number of grid lines
//   nolabel: no label when empty

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

f=fun+"(x)";

if nargin < 5 || isempty(np),
   np = 20,
end

[X1,X2]=meshgrid(Lb(1):(Ub(1)-Lb(1))/np:Ub(1),Lb(2):(Ub(2)-Lb(2))/np:Ub(2));

[n1,n2]=size(X1);
ff=zeros(n1,n2);
for i=1:n1,
  for j=1:n2,
     x=[X1(i,j);X2(i,j)];
     S(i,j)=evstr(f);
  end
end

if nargin < 4 || isempty(level),
  mxf=max(max(S));
  mnf=min(min(S));
  level=mnf+(mxf-mnf)*(2.^(([0:10]/10).^2)-1);
end

figure; surf(X1,X2,S);
figure; contour(X1(1,:)',X2(:,1),S',level);
//if nargin < 6 || isempty(nolabel),
//  clabel(v,h);
//end

endfunction
