%% Draw Contours Along Surface Slice
% Create a surface slice through volumetric data and draw contours along the surface of the volume data. Specify the number of contour levels to draw.
% Create V as an array of volume data defined by v = xe^{-x^2-y^2-z^2}. Then, show a slice of the volume data along the surface defined by z = x^2 - y^2. Draw 20 contours along the surface. Change the axes view to a 3-D view and add grid lines.

[X,Y,Z] = meshgrid(-5:0.2:5);
V = X.*exp(-X.^2-Y.^2-Z.^2);

[xsurf,ysurf] = meshgrid(-2:0.2:2);
zsurf = xsurf.^2-ysurf.^2;
contourslice(X,Y,Z,V,xsurf,ysurf,zsurf,20)
view(3)
grid on

% Copyright 2012 The MathWorks, Inc.