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
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.