Methods for Approximating Function Values - MATLAB & Simulink (original) (raw)

Main Content

About Approximating Function Values

The second stage of a table lookup operation involves generating outputs that correspond to the supplied inputs. If the inputs match the values of indices specified in breakpoint vectors, the block outputs the corresponding values. However, if the inputs fail to match index values in the breakpoint vectors, Simulink® estimates the output. In the block parameter dialog box, you can specify how to compute the output in this situation. The available lookup methods are described in the following sections.

Interpolation Methods

When an input falls between breakpoint values, the block interpolates the output value using neighboring breakpoints. Most lookup table blocks have the following interpolation methods available:

Note

The Lookup Table Dynamic block does not let you select an interpolation method. The Interpolation-Extrapolation option in the Lookup Method field of the block parameter dialog box performs linear interpolation.

Each interpolation method includes a tradeoff between computation time and the smoothness of the result. Although rounding is quickest, it is the least smooth. Linear interpolation is slower than rounding but generates smoother results, except at breakpoints where the slope changes. Cubic spline interpolation is the slowest method but produces smooth results. Akima spline produces the smoothest results.

Extrapolation Methods

When an input falls outside the range of a breakpoint vector, the block extrapolates the output value from a pair of values at the end of the breakpoint vector. Most lookup table blocks have the following extrapolation methods available:

Note

The Lookup Table Dynamic block does not let you select an extrapolation method. The Interpolation-Extrapolation option in the Lookup Method field of the block parameter dialog box performs linear extrapolation.

In addition to these methods, some lookup table blocks, such as the n-D Lookup Table block, allow you to select an action to perform when encountering situations that require extrapolation. For instance, you can specify that Simulink generate either a warning or an error when the lookup table inputs are outside the ranges of the breakpoint vectors. To specify such an action, select it from the Diagnostic for out-of-range input list on the block parameter dialog box.

Rounding Methods

If an input falls between breakpoint values or outside the range of a breakpoint vector and you do not specify interpolation or extrapolation, the block rounds the value to an adjacent breakpoint and returns the corresponding output value. For example, the Lookup Table Dynamic block lets you select one of the following rounding methods:

Example Output for Lookup Methods

In the following model, the Lookup Table Dynamic block accepts a vector of breakpoint data given by [-5:5] and a vector of table data given by sinh([-5:5]).

The Lookup Table Dynamic block outputs the following values when using the specified lookup methods and inputs.

Lookup Method Input Output Comment
Interpolation-Extrapolation 1.4 2.156 N/A
5.2 83.59 N/A
Interpolation-Use End Values 1.4 2.156 N/A
5.2 74.2 The block uses the value forsinh(5.0).
Use Input Above 1.4 3.627 The block uses the value forsinh(2.0).
5.2 74.2 The block uses the value forsinh(5.0).
Use Input Below 1.4 1.175 The block uses the value forsinh(1.0).
-5.2 -74.2 The block uses the value forsinh(-5.0).
Use Input Nearest 1.4 1.175 The block uses the value forsinh(1.0).

See Also

Topics