Methods of approximation of function values
Page in progress. |
About approximation of function values
In the second step of the table lookup operation, the outputs corresponding to the values fed to the input are generated. If the inputs match the index values given in the vectors of reference points, the block outputs the corresponding values. However, if the inputs do not match the index values in the reference point vectors, Engee evaluates the outputs. In the block parameters window, you can specify how to compute the output in this situation. The available search methods are described in the following sections.
Interpolation methods
When the input value falls between reference points, the block interpolates the output value using neighbouring points. The following interpolation methods are available for most lookup table blocks:
-
Flat
- disables interpolation and uses a rounding operation entitledUse 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 neighbouring reference points, the reference point with the higher index is selected. -
Linear point-slope
- draws a line between neighbouring reference points and returns the point on this line corresponding to the input. Line equation:,
,
where is the input data, is the output table data ( is the coordinates of the table data), and is the fraction of the interval (fraction).
-
Cubic spline
- builds a cubic spline based on neighbouring reference points and returns the point on this spline corresponding to the input. -
Linear Lagrange
- constructs a line between neighbouring reference points using first order Lagrange interpolation and returns a point on this line corresponding to the input. Line equation:,
,
where is the input data, is the output table data, and is a fraction, the value of lies in the range
[0,1)
.If the extrapolation method is set to
Linear
, then the extrapolation value is calculated based on the selected linear interpolation method. For example, if the interpolation method is.Linear Lagrange
, then the extrapolation method inherits the linear Lagrange equation to calculate the extrapolated value. -
Akima spline
- constructs an Akima spline based on neighbouring reference points and returns a point on this spline corresponding to the input. The interpolation method works only with the Akima spline extrapolation method. The modified Akima cubic Hermite interpolation method has the following properties:-
It gives less oscillation than cubic spline;
-
It is more efficient for real time applications than cubic spline;
-
Unlike cubic spline, it gives no overshoot.
-
The Lookup Table Dynamic block does not allow you to select an interpolation method. Option Interpolation-Extrapolation for the parameters Lookup Method option means linear interpolation.
|
Each interpolation method involves a trade-off between computation time and smoothness of the result. Although rounding is the fastest, it is the least smooth. Linear interpolation is slower than rounding, but produces smoother results, except at reference points where the slope changes. Cubic spline interpolation is the slowest method but gives smoothed results. Akima spline gives the smoothest results.
Extrapolation methods
When the input signal falls outside the range of the reference vector, the block extrapolates the output value from the pair of values at the end of the reference vector. The following extrapolation methods are available for most lookup table blocks:
-
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 out-of-range values. -
Linear
- If the interpolation method is linear, this extrapolation method draws a line between 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. If the interpolation method isCubic spline
orAkima spline
, then this extrapolation method constructs 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 isLinear Lagrange
, then the extrapolation method inherits the linear Lagrange equation to calculate the extrapolated value. -
Cubic spline
- constructs 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
- constructs an Akima spline based on the first or last pair of anchor points, depending on whether the input is less than the first or greater than the last anchor point, respectively. This method returns the point on the spline corresponding to the input.
The Lookup Table Dynamic block does not allow you to select an extrapolation method. Option Interpolation-Extrapolation in the field Lookup Method of the block parameters window performs linear extrapolation.
|
Rounding methods
If the input value is between reference points or outside the range of a vector of reference points and no interpolation or extrapolation is specified, the block rounds the value to the neighbouring reference point and returns the corresponding output value. For example, the Lookup Table Dynamic block 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 that is lower 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 reference point value 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, the reference point value closest to the input value is returned.