Documentation |
Interpolation for 1-D, 2-D, 3-D, and N-D gridded data in ndgrid format
In a future release, interpn will not accept mixed combinations of row and column vectors for the sample and query grids. For more information, and recommendations for updating your code, see Functionality being removed or changed.
Vq = interpn(X1,X2,...,Xn,V,Xq1,Xq2,...,Xqn) returns interpolated values of a function of n variables at specific query points using linear interpolation. The results always pass through the original sampling of the function. X1,X2,...,Xn contain the coordinates of the sample points. V contains the corresponding function values at each sample point. Xq1,Xq2,...,Xqn contain the coordinates of the query points.
Vq = interpn(V,Xq1,Xq2,...,Xqn) assumes a default grid of sample points. The default grid consists of the points, 1,2,3,...n_{i} in each dimension. The value of n_{i} is the length of the ith dimension in V. Use this syntax to when you want to conserve memory and are not concerned about the absolute distances between points.
Vq = interpn(___,method) specifies an optional, trailing input argument that you can pass with any of the previous syntaxes. The method argument can be any of the following strings that specify alternative interpolation methods: 'linear', 'nearest', 'pchip','cubic', or 'spline'. The default method is 'linear'.
Vq = interpn(___,method,extrapval) also specifies extrapval, a scalar value that is assigned to all queries that lie outside the domain of the sample points.
If you omit the extrapval argument for queries outside the domain of the sample points, then based on the method argument interpn returns one of the following:
The extrapolated values for the 'spline' method
NaN values for interpolation methods other than 'spline'