Navigation

Operators and Keywords

Function List:

C++ API

: vi = interp3 (x, y, z, v, xi, yi, zi)
: vi = interp3 (v, xi, yi, zi)
: vi = interp3 (v, n)
: vi = interp3 (v)
: vi = interp3 (…, method)
: vi = interp3 (…, method, extrapval)

Three-dimensional interpolation.

Interpolate reference data x, y, z, v to determine vi at the coordinates xi, yi, zi. The reference data x, y, z can be matrices, as returned by meshgrid, in which case the sizes of x, y, z, and v must be equal. If x, y, z are vectors describing a cubic grid then length (x) == columns (v), length (y) == rows (v), and length (z) == size (v, 3). In either case the input data must be strictly monotonic.

If called without x, y, z, and just a single reference data matrix v, the 3-D region x = 1:columns (v), y = 1:rows (v), z = 1:size (v, 3) is assumed. This saves memory if the grid is regular and the distance between points is not important.

If called with a single reference data matrix v and a refinement value n, then perform interpolation over a 3-D grid where each original interval has been recursively subdivided n times. This results in 2^n-1 additional points for every interval in the original grid. If n is omitted a value of 1 is used. As an example, the interval [0,1] with n==2 results in a refined interval with points at [0, 1/4, 1/2, 3/4, 1].

The interpolation method is one of:

"nearest"

Return the nearest neighbor.

"linear" (default)

Linear interpolation from nearest neighbors.

"cubic"

Piecewise cubic Hermite interpolating polynomial—shape-preserving interpolation with smooth first derivative (not implemented yet).

"spline"

Cubic spline interpolation—smooth first and second derivatives throughout the curve.

extrapval is a scalar number. It replaces values beyond the endpoints with extrapval. Note that if extrapval is used, method must be specified as well. If extrapval is omitted and the method is "spline", then the extrapolated values of the "spline" are used. Otherwise the default extrapval value for any other method is "NA".

See also: interp1, interp2, interpn, meshgrid.

Package: octave