function vi(index,x,y,varargin)
%VI - plot a field
%
%   This function plots a field of values mapped on a triangulation.
%   Input: index,x,y,field,#of the window   
%   This routine seems to be obsolete... move to Trash?
%
%   Usage:
%      vi(index,x,y,varargin)

num=varargin{nargin-3};
figure(num),clf

test=zeros(nargin-4,1);
for n=1:nargin-4,
   test(n)=length(varargin{n});
end

m=ceil(sqrt(length(find(test~=2))))
count=1;
for n=1:nargin-4,
   if test(n)==2,
      caxis(varargin{n}),colorbar;
   else
      subplot(m,m,count)
      if length(varargin{n})==length(x),
         trisurf(index,x,y,varargin{n}),shading interp, view(2),colorbar
      else
         patch(x(index)',y(index)',[1; 1; 1]*varargin{n}'),shading interp,view(2),colorbar
      end
      
   xlim([min(x) max(x)]);
   ylim([min(y) max(y)]);
   hold on
   title(inputname(3+n))
   count=count+1;
   end
end
