function PlotSolution(u,N,T,P);
% PLOTSOLUTION plots a solution given on a triangular mesh
%   PlotSolution(u,N,T,P); plots the solution vector u on the mesh
%   given by nodes N and triangles T also coding u using color.
%   Note that often view([0 90]) then gives a good 2d color contour plot.
%   If the fourth argument P is given, then according to P the color is
%   shifted

for i=1:size(T,1),
  if nargin==4 & ~isempty(P) & P(i)<=1
    patch(N(T(i,1:3),1),N(T(i,1:3),2),u(T(i,1:3)),u(T(i,1:3)),'EdgeColor','none');
  else
    patch(N(T(i,1:3),1),N(T(i,1:3),2),u(T(i,1:3)),u(T(i,1:3)));
  end
end;
colorbar;
