[ILNumerics Interpolation Toolbox]
Namespace: ILNumerics.Toolboxes
Assembly: ILNumerics.Toolboxes.Interpolation (in ILNumerics.Toolboxes.Interpolation.dll) Version: 5.5.0.0 (5.5.7503.3146)
public static RetArray<float> interp2s( InArray<float> V, InArray<float> X1, InArray<float> X2, InArray<float> Xn1, InArray<float> Xn2, InterpolationMethod method = InterpolationMethod.linear )
Parameters
- V
- Type: ILNumericsInArraySingle
Known values, specified as matrix in meshgrid format. - X1
- Type: ILNumericsInArraySingle
Sample positions of grid points along the rows of V, specified as a matrix in meshgrid format or as vector, or null for auto uniform range. - X2
- Type: ILNumericsInArraySingle
Sample positions of grid points along the columns of V, specified as a matrix in meshgrid format or as vector, or null for auto uniform range. - Xn1
- Type: ILNumericsInArraySingle
Query points X-coordinates, real array of arbitrary shape. - Xn2
- Type: ILNumericsInArraySingle
Query points Y-coordinates, real array of arbitrary shape. - method (Optional)
- Type: ILNumerics.ToolboxesInterpolationMethod
[Optional] Interpolation method. Default: linear
Return Value
Type: RetArraySingleInterpolated values at query points given in Xn1 and Xn2.
Exception | Condition |
---|---|
ArgumentNullException | If input parameter V is NULL |
ArgumentException | If argument X1 or X2 are found to be not strictly monotonically ascending. |
ArgumentException | If arguments Xn1 and Xn2 have different number of elements. |
interp2s(InArraySingle, NullableSingle, InArraySingle, InArraySingle, InArraySingle, InArraySingle, InterpolationMethod) performs interpolation of individual scattered points on the two-dimensional domain V. While V corresponds to a rectilinear grid with uniform or non-uniform ranges for any dimension, new query points for interpolation are scattered and not arranged in a grid. The query points for interpolation are specified dimension-wise in Xn1 and Xn2. Therefore, the number of elements in Xn1 and Xn2 must match. Xn1 specifies the coordinates in the first dimension (X coordinates) of the query points, corresponding to the direction of the rows in V. Xn2 specifies the coordinates in the second dimension (Y coordinates) of the query points, corresponding to the direction of the columns in V. None of Xn1 and Xn2 can be null.
The positions of the grid elements in V are specified in X1 for the rows in V and X2 for the columns in V. Any dimension specified as null in X1 or X2 are considered as auto-ranged with values from 0...size(V,0)-1 or 0...size(V,1)-1 correspondingly. Otherwise, X1 and X2 must be arrays with strictly monotonically increasing elements.
Any interpolation method out of the enum InterpolationMethod is supported, with the exception of polynomial and parabolic. By default, linear interpolation is performed.
Any elements outside of the domain of V are marked as NaN (not a number).
V may contain NaN values. Depending on the interpolation method used interpolated query points on surronding hypercubes will return NaN as well.
Any elements in Xn1 or Xn2 being NaN will cause the corresponding interpolation result to be considered as 'out of range: NaN will be assigned to it.
The array returned is of size 2 x n, where n corresponds to the number of elements in Xn1 and Xn2.
[ILNumerics Interpolation Toolbox]
//generate any meshgrid [-1:1] Array<float> Y = 1.0f; Array<float> X = meshgrid(linspace<float>(-1, 1, 20), linspace<float>(-1, 1, 20), Y); Array<float> V = sqrt(1 - X * X - Y * Y); //define random generated scattered points [-1:1] Array<float> Xn = 2 * rand(3000, 1) - 1; Array<float> Yn = 2 * rand(3000, 1) - 1; //Interpolate Array<float> Vq = Interpolation.interp2s(V, X1, X2, Xn1, Xn2, method:InterpolationMethod.linear, outOfRangeValues: float.NaN); //or spline interpolation without range definition Array<float> Vq = Interpolation.interp2s(V, Xn1:Xn, Xn2:Yn, method:InterpolationMethod.spline); //this two function calls returns an empty array, because query points not set Array<float> Vq = Interpolation.interp2s(V, X1, X2, method:InterpolationMethod.nearest); //or Array<float> Vq = Interpolation.interp2s(V);