interpn

N dimensional interpolation.

Syntax

Vi = interpn(x1,x2,x3,...,xn,V,x1i,x2i,x3i,...,xin)

Vi = interpn(V,x1i,x2i,x3i,...,xin)

Vi = interpn(V)

Vi = interpn(V,m)

Vi = interpn(...,method)

Vi = interpn(...,method,extrap)

Inputs

x1,x2,x3,...xn
The point coordinate values with which to interpolate, with each argument corresponding to a dimension of V.
If the arguments are vectors then they are assumed to be monotonically increasing, with lengths equal to the dimension lengths V. If the arguments are matrices then they must be in the ndgrid format.
When omitted, each ith argument defaults to the vector 1:size(V(i)).
Type: double
Dimension: vector | matrix
V
The ND grid of function values over which to interpolate.
Type: double
Dimension: matrix
x1i,x2i,x3i,...,xni
The interpolated point coordinates, with each argument corresponding to a dimension of V.
If arguments are vectors then their lengths determine the dimension lengths of Vi. If arguments are matrices then they must be in the ndgrid format.
Type: double
Dimension: scalar | vector | matrix
m
The number of bisections performed on intervals of V when no coordinate arguments are supplied (default: 1).
Type: integer
Dimension: scalar
method
The available options are:
'linear' (default)
Returns the multilinear interpolation.
'spline' (not yet available)
Returns the cubic spline interpolation.
Type: string
extrap
The available options are:
'extrapVal' (default: NaN)
Out of bounds values are set to this scalar value. Setting a value requires use of the method argument.
'extrap'
Allows extrapolation beyond the intervals using the current method.
'noextrap'
Does not allow extrapolation.

Outputs

Vi
The interpolated values corresponding to the xni locations.
Dimension: matrix

Examples

Plot interpolated values over a sparsely sampled paraboloid.

x = [-2:0.5:2];
y = [-2:0.5:2];
func = @(x,y) 1 - x.^2 - y.^2;
[xx, yy] = meshgrid(x, y);
V = func(xx,yy);
xi = [-2:0.1:2];
yi = [-2:0.1:2];
Vi = interpn(x, y, V, xi, yi);
[xxi, yyi] = ndgrid(xi, yi);
mesh (xxi, yyi, vi);
Figure 1. interpn figure 1


Comments

The function allows interpolation in 1 dimension when V is a column vector, though interp1 would be more efficient.