%% Volume Data Along Surface
% Show volumetric data along a nonplanar slice. Define the surface where you want to show the volumetric data.
% Create volume array V as the volume defined by v = xe^{-x^2-y^2-z^2}, where x, y, and z range from [-5,5]. Then, show a slice of the volume data along the surface defined by $z = x^2 - y^2$.
%

[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;
slice(X,Y,Z,V,xsurf,ysurf,zsurf)

% Copyright 2012 The MathWorks, Inc.