function ShowVectorField(nodes,vectors,factor)
%ShowVectorField(nodes,vectors,factor)
%  shows a vector field plot of a numerical solution of the PDE
%
% nodes    the coordinates of the points at which the vector field was computed
% vectors  components of the vectorfield at nodes
% factor   vector field is rescaled by this factor, if given
%   
%     if the argument factor is not specified an appropriate 
%     default value will be choosen
%
%see also ReadMesh, ShowMesh, FEMEquation, FEMSolve, FEMValue

if (nargin > 1)
  a=size(nodes);
  b=size(vectors);
  c= a==b;
  d= a(1,2)==2;
  e=[d 1];
  f=c==e;
  g=f(1,1)&f(1,2);
  if (g==1)
    if(nargin==2)
      x=nodes(:,1);
      y=nodes(:,2);
      dx=max(x)-min(x);
      dy=max(y)-min(y);
      maxD=max([dx, dy]);
      maxD=maxD*0.06;
      dx=vectors(:,1);
      dy=vectors(:,2);
      dx=dx .* dx;
      dy=dy .* dy;
      maxV=dy+dx;
      maxV=sqrt(dy+dx);
      maxV=max(maxV);
      factor_= maxD / maxV;
    else 
      factor_=factor;
    end
    vectors_=vectors*factor_;
    Matrix=[nodes vectors_];
    gset data style vector;
    gset nokey
    gset nolabel
    gset autoscale xy
    fem="with vector 1";
    cmd = sprintf ("gplot Matrix %s" , fem);
    eval (cmd);
    gset data style lines;
  else
    disp("\nMatrixgroessen stimmen nicht ueberein \n")
  end
else
  usage("ShowVectorField(nodes,vectors,factor) \n ShowVectorField(nodes,vectors,factor) \n")
end	

endfunction


