Engee documentation

Methods for approximating function values

On the approximation of function values

At the second stage of the table search operation, outputs corresponding to the input values are generated. If the inputs match the values of the indexes specified in the anchor point vectors, the block outputs the corresponding values. However, if the input data does not match the values of the indexes in the anchor point vectors, then Engee evaluates the output data. In the block parameters window, you can specify how to calculate the output in this situation. The available search methods are described in the following sections.

Interpolation methods

When the input value falls between the reference points, the block interpolates the output value using adjacent points. The following interpolation methods are available for most blocks of the search tables:

  • Flat — disables interpolation and uses a rounding operation called Use Input Below.

  • Nearest — disables interpolation and returns the table value corresponding to the reference point closest to the input. If the input signal is equidistant from two adjacent reference points, then a reference point with a higher index is selected.

  • Linear point-slope — draws a line between adjacent anchor points and returns the point on this line corresponding to the input. Equation of the line:

    ,

    ,

    where — input data, — output table data ( — coordinates of the table data), and — the fraction of the interval (fraction).

  • Cubic spline — builds a cubic spline based on neighboring reference points, and returns a point on this spline corresponding to the input.

  • Linear Lagrange — builds a line between adjacent reference points using first-order Lagrange interpolation, and returns a point on this line corresponding to the input. Equation of the line:

    ,

    ,

    where — input data, — output table data, and — fraction, value it lies in the range of `[0,1)'.

    If the extrapolation method is relevant Linear, the extrapolation value is calculated based on the selected linear interpolation method. For example, if the interpolation method — Linear Lagrange, then the extrapolation method inherits the linear Lagrange equation to calculate the extrapolated value.

  • Akima spline — builds Akim’s spline based on neighboring reference points and returns a point on this spline corresponding to the input. The interpolation method only works with Akim’s spline extrapolation method. Akim’s modified cubic Hermitian interpolation method has the following properties:

    • It gives less vibrations than a cubic spline.;

    • It is more efficient for real-time applications than cubic spline.;

    • Unlike the cubic spline, it does not slip.

Block Lookup Table Dynamic It does not allow you to select an interpolation method. Option Interpolation-Extrapolation for the parameter Lookup Method means performing linear interpolation.

Each interpolation method involves a compromise between the calculation time and the smoothness of the result. Although rounding is the fastest, it is the least smooth. Linear interpolation is slower than rounding, but it gives smoother results, except for the reference points where the slope varies. Cubic spline interpolation is the slowest method, but it gives smooth results. Akim’s spline gives the smoothest results.

Extrapolation methods

When the input signal is outside the range of the anchor vector, the block extrapolates the output value from the pair of values at the end of the anchor vector. The following extrapolation methods are available for most blocks of the search tables:

  • Clip — disables extrapolation and returns the table data corresponding to the end of the range of the reference point vector. This does not provide protection against values outside the range.

  • Linear — if the interpolation method is linear, then this extrapolation method builds a line between the first or last pair of reference points, depending on whether the input signal is smaller than the first or greater than the last reference point. If the interpolation method is — Cubic spline or Akima spline then this extrapolation method builds a linear surface using the slope of the interpolation at the first or last reference point, depending on whether the input signal is less than the first or greater than the last reference point. The extrapolation method returns a point on the generated linear surface corresponding to the input.

    If the extrapolation method Linear, the extrapolation value is calculated based on the selected linear interpolation method. For example, if the interpolation method Linear Lagrange, then the extrapolation method inherits the linear Lagrange equation to calculate the extrapolated value.

  • Cubic spline — builds a cubic spline based on the first or last pair of reference points, depending on whether the input signal is less than the first or greater than the last reference point, respectively. This method returns the point on the spline corresponding to the input.

  • Akima spline — builds Akim’s spline based on the first or last pair of reference points, depending on whether the input signal is less than the first or greater than the last reference point, respectively. This method returns the point on the spline corresponding to the input.

Block Lookup Table Dynamic It does not allow you to select the extrapolation method. Option Interpolation-Extrapolation in the field Lookup Method The block parameter window performs linear extrapolation.

Rounding methods

If the input value is between the reference points or outside the range of the reference point vector and no interpolation or extrapolation is specified, the block rounds the value to the adjacent reference point and returns the corresponding output value. For example, the block Lookup Table Dynamic allows you to select one of the following rounding methods:

  • Use Input Nearest — returns the output value corresponding to the nearest input value.

  • Use Input Below — returns the output value corresponding to the value of the reference point, which is smaller and at the same time closest to the input value. If there is no reference point below the input value, the reference point value closest to the input value is returned.

  • Use Input Above — returns the output value corresponding to the value of the reference point that is larger and at the same time closest to the input value. If there is no reference point value higher than the input value, then the reference point closest to the input value is returned.