[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<complex> interp2( InArray<complex> V, Nullable<complex> outOfRangeValues, InArray<double> X1 = null, InArray<double> X2 = null, InArray<double> Xn1 = null, InArray<double> Xn2 = null, int k = 0, InterpolationMethod method = InterpolationMethod.linear )
Parameters
- V
- Type: ILNumerics.InArray<complex>
Matrix with sample values defined in meshgrid format. - outOfRangeValues
- Type: System.Nullable<complex>
Scalar value used to mark values whose position lays outside the range defined by X1 and X2. Null: extrapolate. - X1 (Optional)
- Type: ILNumerics.InArray<Double>
[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: ILNumerics.InArray<Double>
[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: ILNumerics.InArray<Double>
[Optional] Query point positions for dimension 1 (rows), specified as grid vector or matrix in meshgrid format. Monotonically increasing. - Xn2 (Optional)
- Type: ILNumerics.InArray<Double>
[Optional] Query point positions for dimension 2 (columns), specified as grid vector or matrix in meshgrid format. Monotonically increasing. - k (Optional)
- Type: System.Int32
[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.Toolboxes.InterpolationMethod
[Optional] Interpolation method. Default: linear.
Return Value
Type: RetArray<complex>Matrix 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(InArray<complex> , Nullable<complex> , InArray<Double> , InArray<Double> , InArray<Double> , InArray<Double> , Int32, InterpolationMethod) performs two dimensional interpolation over the given data matrix V defined in meshgrid(InArray<complex> , InArray<complex> , InArray<complex> , OutArray<complex> , OutArray<complex> ) 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(InArray<complex> , Nullable<complex> , 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<complex>, complex?, InArray<complex>, InArray<complex>, int, InterpolationMethod)] for a detailed description.
[ILNumerics Interpolation Toolbox]
//generate any meshgrid Array<complex> X2 = 1; Array<complex> X1 = meshgrid(linspace<complex>(-2, 2, 20), linspace<complex>(-2, 2, 20), X2); Array<complex> V = X1 * exp(-(X1 * X1 + X2 * X2)); //define query meshgrid Array<complex> Xn2 = 1; Array<complex> Xn1 = meshgrid(linspace<complex>(-3, 3, 50), linspace<complex>(-3, 3, 50), Xn2); //Interpolate Array<complex> Vq = Interpolation.interp2(V, X1, X2, Xn1, Xn2, method:InterpolationMethod.spline, outOfRangeValues: complex.NaN); //or spline interpolate using refinement factor Array<complex> Vq = Interpolation.interp2(V, X1, X2, k:2, method:InterpolationMethod.spline); //or nearest neighbor interpolation of a meshgrid with only one Xn2 specified. Array<complex> Vq = Interpolation.interp2(V, X1, X2, Xn2:Xn2, method:InterpolationMethod.nearest); //or linear interpolate a meshgrid Array<complex> Vq = Interpolation.interp2(V);