%GRID_CONTOUR % % Usage: % grid_contour(xPts, yPts, zPts, xSpacing, ySpacing, zInterval, useNumBlocks) % % This function adds a contour plot of the provided data to the current % figure, and plots the data on top of the contour plot. It will also plot % markers showing the locations of the selected grid points. % % 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. % zInterval: Desired spacing between contour lines. % 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 grid_contour(xPts, yPts, zPts, xSpacing, ySpacing, zInterval, useNumBlocks) [X Y Z] = createGrid(xPts, yPts, zPts, xSpacing, ySpacing, 'linear', useNumBlocks); hold on % Create an array of the contour positions intervals = [floor(min(min(Z))):zInterval:max(max(Z))]; % Draw the contours to the current figure. [c,h] = contourf(X,Y,Z,intervals); % Draw the original points. plot(xPts, yPts, 'k.') %Plot the grid points plot(X,Y,'+') axis equal clabel(c,h);%,'manual'); %Draw all contour labels colorbar; hold off