smartSlice and iGSlice

slice into irregular grids with smartSlice and iGSlice. NaN values are allowed.
1.2K Downloads
Updated 23 Jan 2011

View License

slice.m does not allow non-monotonic matrices or NaN values.
However, a 3D volume may often meet these limitations. For example, a 3D grid may be constructed first by 2D interpolations of scattered Z values to xy grids (such as topography at different depths), and then a 3D interpolation of data values.

smartSlice and iGSlice are 2 alternatives that allow non-monotonic arrays and NaNs in Z and V.

smartSlice.m offers quick slicing in the xy planes by selecting the grid plane which is closest to the input values along which to slice (within a search radius). This is ideal for dense datasets which are relatively closely spaced, or for situations in which an exact slice location is not required.

For precise slicing, use iGSlice.
iGslice allows non-monotonic Z,V arrays and NaNs. Slice planes are constructed by 2D interpolation of each 'layer' of Z into the xy plane, where the ith layer of Z is Z(:,:,i). V is then interpolated across the plane using a 3D scattered interpolant. For slicing in the Z plane, 2D interpolation is not required since Z is equal.

use help iGSlice
help smartSlice

Notes, limitations, future updates:

1. For monotonic arrays slice is preferred to iGSlice. iGSlice offers a solution to the problem of slicing on an irregular grid. However, if the users desired output matches the capabilities of smartSlice, this offers the best performance.
2. Calling iGSlice/smartSlice is similar to calling slice. see help iGSlice for more.
3. iGSlice employs griddata for the 2D interpolation. Matlab urges the use of TriScatteredInterp instead, however this does not allow NaN or matrices.
4.iGSlice employs TriScatteredInterp for 3D interpolation. Calling iGSlice with the interpolant already constructed should increase performance for repeated calls.
5. Be warned that iGSlice is slow compared to slice. This is because of the extra weight of having to perform 2 scattered interpolations rather than 1 grid interpolation. Any suggestions to improve performance are welcome.
Where possible, the use of smartSlice is reccomended.
6.It has been noted that slices in the Y plane may appear distorted when using smartSlice. The solution is to switch from openGL to zbuffer.
7. Possible updates:
-Add all functionality available in slice.
-update smartSlice to decide automatically if quickSlice or iGSlice is required.
-

Cite As

James Ramm (2024). smartSlice and iGSlice (https://www.mathworks.com/matlabcentral/fileexchange/30147-smartslice-and-igslice), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0