[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<fcomplex> interp2( InArray<fcomplex> V, Nullable<fcomplex> outOfRangeValues, InArray<float> X1 = null, InArray<float> X2 = null, InArray<float> Xn1 = null, InArray<float> Xn2 = null, int k = 0, InterpolationMethod method = InterpolationMethod.linear )
Parameters
- V
- Type: ILNumericsInArrayfcomplex
Matrix with sample values defined in meshgrid format. - outOfRangeValues
- Type: SystemNullablefcomplex
Scalar value used to mark values whose position lays outside the range defined by X1 and X2. Null: extrapolate. - X1 (Optional)
- Type: ILNumericsInArraySingle
[Optional] Positions of grid points along the rows of V, specified as a matrix in meshgrid format or grid vector. Monotonically increasing along the rows. - X2 (Optional)
- Type: ILNumericsInArraySingle
[Optional] Positions of grid points along the columns of V, specified as a matrix in meshgrid format or grid vector. Monotonically increasing along the columns. - Xn1 (Optional)
- Type: ILNumericsInArraySingle
[Optional] Query point positions for dimension 1 (rows), specified as grid vector or matrix in meshgrid format. Monotonically increasing. - Xn2 (Optional)
- Type: ILNumericsInArraySingle
[Optional] Query point positions for dimension 2 (columns), specified as grid vector or matrix in meshgrid format. Monotonically increasing. - k (Optional)
- Type: SystemInt32
[Optional] Refinement factor for default query grid positions. Ranges specified by X1 and/or X2 are split k times. Ignored for Xn1 or Xn2 being not null respectively. Default: 1. - method (Optional)
- Type: ILNumerics.ToolboxesInterpolationMethod
[Optional] Interpolation method. Default: linear.
Return Value
Type: RetArrayfcomplexMatrix with interpolated values. Corresponds to the grid determined by Xn1 and Xn2.
Exception | Condition |
---|---|
ArgumentNullException | If input parameter V is NULL |
ArgumentException | If argument X1 or X2 are not not strictly monotonically increasing. |
ArgumentException | If argument method is set as global polynomial for more than 9 sample points X1 or X2 |
ArgumentException | If arguments X1 or X2 do not match the size of V. |
interp2(InArrayfcomplex, Nullablefcomplex, InArraySingle, InArraySingle, InArraySingle, InArraySingle, Int32, InterpolationMethod) performs two dimensional interpolation over the given data matrix V defined in meshgrid(InArrayfcomplex, InArrayfcomplex, InArrayfcomplex, OutArrayfcomplex, OutArrayfcomplex) format. The parameter X1 specifies the positions of the grid points in V along the first dimension (along the rows of V). X2 determines the positions along the 2nd dimension (along the columns of V). Hence, V forms a regular, rectilinear grid of (non-)uniform spacing. Note the order of the dimensions in V: as determined by the meshgrid function the first dimension is considered to correspond to the rows instead of the columns. This order is useful for visualization purposes and plotting, where the X axis is commonly expected along the rows. Use interpn(InArrayfcomplex, Nullablefcomplex, InCell, InCell, InterpolationMethod) as an alternative.
Values in X1 and X2, if provided, must be strictly monotonically increasing but not necessarily be uniform. If any of X1 and/or X2 are ommitted, default grid positions are assumed with uniform range of spacing 1: 0:n x 0:m, where [m+1,n+1] = size(V).
Values in Xn1 and Xn2, if provided, must be strictly monotonically increasing but not necessarily uniform. If any of Xn1 and/or Xn2 are ommitted, default query grid positions are assumed by subdividing X1 and/or X2 respectively, 'k' times.
Interpolation methods: all methods from the enum InterpolationMethod are supported. See [!:interp1(InArray<fcomplex>, fcomplex?, InArray<fcomplex>, InArray<fcomplex>, int, InterpolationMethod)] for a detailed description.
[ILNumerics Interpolation Toolbox]
//generate any meshgrid Array<fcomplex> X2 = 1; Array<fcomplex> X1 = meshgrid(linspace<fcomplex>(-2, 2, 20), linspace<fcomplex>(-2, 2, 20), X2); Array<fcomplex> V = X1 * exp(-(X1 * X1 + X2 * X2)); //define query meshgrid Array<fcomplex> Xn2 = 1; Array<fcomplex> Xn1 = meshgrid(linspace<fcomplex>(-3, 3, 50), linspace<fcomplex>(-3, 3, 50), Xn2); //Interpolate Array<fcomplex> Vq = Interpolation.interp2(V, X1, X2, Xn1, Xn2, method:InterpolationMethod.spline, outOfRangeValues: fcomplex.NaN); //or spline interpolate using refinement factor Array<fcomplex> Vq = Interpolation.interp2(V, X1, X2, k:2, method:InterpolationMethod.spline); //or nearest neighbor interpolation of a meshgrid with only one Xn2 specified. Array<fcomplex> Vq = Interpolation.interp2(V, X1, X2, Xn2:Xn2, method:InterpolationMethod.nearest); //or linear interpolate a meshgrid Array<fcomplex> Vq = Interpolation.interp2(V);