interp3
Interpolation of data on a 3-D grid.
Category: Mathematics > Interpolation
Syntax
Vq = interp3(X, Y, Z, V, Xq, Yq, Zq)
Linear interpolation of V sampled on the grid (X,Y,Z) at the query points.
Vq = interp3(V, Xq, Yq, Zq)
Assumes the grid is made of the index values of V.
Vq = interp3(..., method, extrapval)
Selects the method and a fill value for points outside the grid.
Description
interp3 extends interp2 to volumes, using the same meshgrid orientation: the first index of V follows Y, the second follows X, the third follows Z. The linear method is trilinear, averaging the eight corners of the cell that holds the query point.
Input arguments
X, Y, Z- Grid coordinates, as
meshgridarrays or as vectors. V- 3-D array of values.
Xq, Yq, Zq- Query coordinates.
Output arguments
Vq- Interpolated values, with
NaNoutside the grid by default.
Example
Trilinear lookup
[X, Y, Z] = meshgrid(1:3);
V = X + 10*Y + 100*Z;
interp3(X, Y, Z, V, 1.5, 2.5, 1.5)
Output
ans = 176.5000