%BASIC_CONTOUR % % Usage: % basic_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 point locations on top of the contour 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. % 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 basic_contour(xPts, yPts, zPts, xSpacing, ySpacing, zSpacing, useNumBlocks) [X Y Z] = createGrid(xPts, yPts, zPts, xSpacing, ySpacing, 'linear', useNumBlocks); hold on axis equal % Create an array of the contour positions intervals = [floor(min(min(Z))):zSpacing: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.') clabel(c,h);%,'manual'); %Draw all contour labels colorbar; hold off %{ * Contour map WITH original data points Input should be original x,y,z data, # of x blocks, # of y blocks OPTIONAL: you could decide to input x and y spacing instead of number of blocks %}