% V - vertex data, E - element data (see readmesh.m), U - the values % of the function we're plotting on the vertices. function plot_surf(V,E,U) % Get our coordinates as stand-alone vectors, so % that we can easily index them with (the matrix) E Vx = V(:,1); Vy = V(:,2); Vz = U; % Create and plot the patches (1 patch = 1 element) fig=gcf; clf(fig); patch(Vx(E'),Vy(E'), Vz(E'), Vz(E')); grid on; % Set a different perspective than the default one. set(gca,'Projection','perspective'); view(3); cam_pos=get(gca,'CameraPosition'); tar_pos=get(gca,'CameraTarget'); cam_pos=0.3.*(cam_pos-tar_pos)+tar_pos; set(gca,'CameraPosition',cam_pos); end