%% Contour Slices Along Spherical Surface
% Set up matrices X, Y, and Z using the meshgrid function.

x = -2:0.2:2;
y = -2:0.25:2;
z = -2:0.16:2;
[X,Y,Z] = meshgrid(x,y,z);

%
% Use X, Y, and Z to define V as a matrix of volume data.

V = X.*exp(-X.^2-Y.^2-Z.^2);

%
% Return matrices Xi, Yi, and Zi from the sphere function.

[Xi,Yi,Zi] = sphere;

%
% Draw contours through the volume V along the surface defined by Xi, Yi, and Zi. Change the plot view to a 3-D view.

contourslice(X,Y,Z,V,Xi,Yi,Zi)
view(3)

% Copyright 2015 The MathWorks, Inc.