| MATLAB Functions | Help Desk |
slice
Volumetric slice plotslice(V,sx,sy,sz)
slice(X,Y,Z,V,sx,sy,sz)
slice(V,XI,YI,ZI)
slice(X,Y,Z,V,XI,YI,ZI)
slice(...,'method')
h = slice(...)
slice displays volumetric data. You indicate the portion of the data you want to view by specifying a slice plane or surface.
slice(V,sx,sy,sz)
draws data in the volume V for the slices defined by sx, sy, and sz. V is an m-by-n-by-p volume array containing data values at the default location X = 1:n, Y = 1:m, Z = 1:p. Each element in the vectors sx, sy, and sz defines a slice plane in the x-, y-, or z-axis direction.
slice(X,Y,Z,V,sx,sy,sz)
draws slices of the volume V. X, Y, and Z are three-dimensional arrays specifying the coordinates for V. X, Y, and Z must be monotonic and orthogonally spaced (e.g., produced by the function meshgrid).
slice(V,XI,YI,ZI)
draws data in the volume V for the slices defined by XI, YI, and ZI. XI, YI, and ZI are matrices that define a surface and the volume is evaluated at the surface points. XI, YI, and ZI must all be the same size.
slice(X,Y,Z,V,XI,YI,ZI)
draws slices of the volume V. X, Y, and Z are three-dimensional arrays specifying the coordinates for V. X, Y, and Z must be monotonic and orthogonally spaced (e.g., produced by the function meshgrid).
slice(...,'method')
specifies the interpolation method. 'method' is 'linear', 'cubic', or 'nearest'. 'linear' is the default.
'linear' specifies trilinear interpolation.
'cubic' specifies tricubic interpolation.
'nearest' specifies 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 V.
Visualize the function
over the range -2
x
2, -2
y
2, - 2
z
2:
[x,y,z] =meshgrid(-2:.2:2, -2:.25:2, -2:.16:2); v = x.*exp(-x.^2-y.^2-z.^2); xslice = [-1.2 .8 2]; yslice = 2; zslice = [-2 0];slice(x,y,z,v,xslice,yslice,zslice)
![]()
meshgrid
The interp3 function in the online MATLAB Function Reference.