function splotfem(p,t,U,type);
%function splotfem(p,t,U,type);
% Same as plotfem by Hanninen-Vehvilainen, except mesh -> surf
%    (makes it slower)
%type:
%	1=mesh
%	2=plot3

n=size(t,2);
fnum=gcf;
clf
hold on
for i=1:n
    X=[p(1,t(1,i)),p(1,t(2,i)); p(1,t(2,i)),p(1,t(3,i)); p(1,t(3,i)),p(1,t(1,i))];
    Y=[p(2,t(1,i)),p(2,t(2,i)); p(2,t(2,i)),p(2,t(3,i)); p(2,t(3,i)),p(2,t(1,i))];
    Z=[U(t(1,i)),U(t(2,i)); U(t(2,i)),U(t(3,i)); U(t(3,i)),U(t(1,i))]; 
    if type==1    
	surf(X,Y,Z)
    else 
	plot3(X,Y,Z,'y-')
    end
end
%mesh(X,Y,Z)
hold off
view(3)
if type==1
    colorbar
    shading interp
end
figure(fnum)
end