|MATLAB Function Reference|
Volumetric slice plot
slice displays orthogonal slice planes through volumetric data.
draws slices along the x, y, z directions in the volume
V at the points in the vectors
V is an m-by-n-by-p volume array containing data values at the default location
X = 1:n,
Y = 1:m,
1:p. Each element in the vectors
sz defines a slice plane in the x-, y-, or z-axis direction.
draws slices of the volume
Z are three-dimensional arrays specifying the coordinates for
Z must be monotonic and orthogonally spaced (as if produced by the function
meshgrid). The color at each point is determined by 3-D interpolation into the volume
draws data in the volume
V for the slices defined by
ZI are matrices that define a surface, and the volume is evaluated at the surface points.
ZI must all be the same size.
draws slices through the volume
V along the surface defined by the arrays
slice(...,' specifies the interpolation method.
linearspecifies trilinear interpolation (the default).
cubicspecifies tricubic interpolation.
nearestspecifies nearest neighbor interpolation.
h = slice(...)
returns a vector of handles to surface graphics objects.
The color drawn at each point is determined by interpolation into the volume
Visualize the function
over the range -2 x 2, -2 y 2, - 2 z 2:
Slicing At Arbitrary Angles
You can also create slices that are oriented in arbitrary planes. To do this,
ZDataof the surface (
For example, these statements slice the volume in the first example with a rotated plane. Placing these commands within a for loop "passes" the plane through the volume along the z-axis.
for i = -2:.5:2 hsp = surf(linspace(-2,2,20),linspace(-2,2,20),zeros(20)+i); rotate(hsp,[1,-1,1],30) xd = get(hsp,'XData'); yd = get(hsp,'YData'); zd = get(hsp,'ZData'); delete(hsp) slice(x,y,z,v,[-2,2],2,-2) % Draw some volume boundaries hold on slice(x,y,z,v,xd,yd,zd) hold off axis tight view(-5,10) drawnow end
The following picture illustrates three positions of the same slice surface as it passes through the volume.
Slicing with a Nonplanar Surface
You can slice the volume with any surface. This example probes the volume created in the previous example by passing a spherical slice surface through the volume.
[xsp,ysp,zsp] = sphere; slice(x,y,z,v,[-2,2],2,-2) % Draw some volume boundaries for i = -3:.2:3 hsp = surface(xsp+i,ysp,zsp); rotate(hsp,[1 0 0],90) xd = get(hsp,'XData'); yd = get(hsp,'YData'); zd = get(hsp,'ZData'); delete(hsp) hold on hslicer = slice(x,y,z,v,xd,yd,zd); axis tight xlim([-3,3]) view(-10,35) drawnow delete(hslicer) hold off end
The following picture illustrates three positions of the spherical slice surface as it passes through the volume.
Volume Visualization for related functions
Exploring Volumes with Slice Planes for more examples.