%PLOT_SURFACE % % Usage: % plot_surface(xPts, yPts, zPts, xSpacing, ySpacing, useNumBlocks) % % This function adds a 3D surface plot of the provided data points tot eh % current figure, and plots the 3D locations of the original data points on % top of the surface plot. % Note that the title, axis labels, etc. must be handled outside of the % function. % % Input arguments: % xPts, yPts, zPts: Arrays of the x-, y-, and z-locations of the data % points. % xSpacing, ySpacing: Desired grid spacing for the plot. Exact meaning depends on % the value of useNumBlocks. % useNumBlocks: Flag to determine how xSpacing and ySpacing are used. % Values: % 0: Treat xSpacing, ySpacing as the distance between % each grid point. % non-0: Select xSpacing evenly-spaced grid points in the % x-direction, and ySpacing evenly-spaced points % in the y-direction. % % Author: Robert Wagner % Date: 2nd March 2009 % Last Modified: 12th March 2009 function plot_surface(xPts, yPts, zPts, xSpacing, ySpacing, useNumBlocks) [X Y Z] = createGrid(xPts, yPts, zPts, xSpacing, ySpacing, 'linear', useNumBlocks); hold on surfl(X,Y,Z) shading interp colormap autumn % Draw the original points. plot3(xPts, yPts, zPts, 'k.') hold off