Table Of Contents

Interpolate 1D (G Dataflow)

Last Modified: March 15, 2017

Performs one-dimensional interpolation using a selected method based on the lookup table defined by arrays of values of dependent and independent variables.

connector_pane_image
datatype_icon

X is monotonic

A Boolean that specifies whether the values of the independent variable are increasing monotonically with the index.

True Does not sort the independent variable or reorder the dependent variable.
False Sorts the independent variable to be in ascending order and reorders the dependent variable accordingly.

Default: False

datatype_icon

method

Interpolation method.

Name Value Description
nearest 0

Chooses the Y value corresponding to the X value that is nearest to the current xi value. This node sets the interpolated value to the nearest data point.

linear 1

Sets the interpolated values to points along the line segments connecting the X and Y data points.

spline 2

Guarantees that the first and second derivatives of the cubic interpolating polynomials are continuous, even at the data points.

cubic Hermite 3

Guarantees that the first derivative of the cubic interpolating polynomials is continuous and sets the derivative at the endpoints to certain values in order to preserve the original shape and monotonicity of the Y data.

Lagrange 4

Uses the barycentric Lagrange interpolation algorithm.

Choosing the Interpolation Method

You can refer to the following facts when you choose among the five interpolation methods:

  • The nearest method and the linear method are simple to use but are too inaccurate in most applications.
  • The spline method returns the smoothest result out of all five methods.
  • The cubic Hermite method has better local property than the spline method and the Lagrange method.
  • The Lagrange method is simple to implement but not suitable for exploratory calculation. When compared to the spline method, the Lagrange method yields the interpolation result with extreme derivatives.

The Nearest Method

The nearest method finds the point nearest to xi in X and then assigns the corresponding y value in Y to yi, as shown in the following graph.

The Linear Method

The linear method interpolates yi on the line segment that connects the two points (xj, xj + 1) when xi is located between the two points (xj, xj + 1) in X, as shown in the following graph.

In the previous graph, the following equation is true:

L j ( x ) = y j + y j + 1 y j x j + 1 x j ( x x j )

The Spline Method

The spline method refers to the cubic spline method. With this method, the node derives a third-order polynomial for each interval between two adjacent points. The polynomials meet the following conditions:

  • The first and second derivatives at xj are continuous.
  • The polynomials pass all the specified data points.
  • The second derivatives at the beginning and end are zero.

The following graph illustrates the cubic spline method.

In the previous graph, Pj(x) is the third-order polynomial between two adjacent points, (xj, yj) and (xj + 1, yj + 1).

The Cubic Hermite Method

The cubic Hermitian spline method is the piecewise cubic Hermitian interpolation. This method derives a third-order polynomial in Hermitian form for each interval and ensures only the first derivatives of the interpolation polynomials are continuous. Compared to the cubic spline method, the cubic Hermitian method has better local property. In other words, if you change one data point xj, the effect on the interpolation result lies in the range between [xj - 1, xj] and [xj, xj + 1].

The Lagrange Method

The Lagrange method derives a polynomial of order N - 1 that passes all the N points specified in X and Y, where N is the length of X and Y. This method is a reformulation of the Newton polynomial that avoids the computation of divided differences. The following equation defines the Lagrange method:

y i m = j = 0 N 1 c j y j

where

  • c j = k = 0 , k j N 1 x i m x k x j x k
  • yim is the m-th element in yi
  • xim is the m-th element in xi

Default: linear

datatype_icon

Y

Tabulated values of the dependent variable.

datatype_icon

X

Tabulated values of the independent variable.

The length of X must equal the length of Y.

datatype_icon

ntimes

Locations of the interpolation points.

This input yields interpolated values between every Y element when xi is empty. Interpolation between Y elements is repeated ntimes.The node ignores ntimes if you wire the xi input.

datatype_icon

error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error

datatype_icon

xi

Array of values of the independent variable at which this node computes the interpolated values of the dependent variable.

datatype_icon

yi

Output array of interpolated values that correspond to the independent variable values.

datatype_icon

xi used

1D array of values of the independent variable at which interpolated values of the dependent variable are computed.

If xi is empty, xi used returns 2ntimes *(N - 1) + 1 points with (2ntimes - 1) points located evenly between each two adjacent elements in X, where N is the length of X. If you wire the xi input, this node ignores ntimes, and xi used is the same as xi.

datatype_icon

error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices


Recently Viewed Topics