Approximate one-dimensional function using dynamic table
Lookup Tables
The Lookup Table Dynamic block computes an approximation of
a function y = f(x)
using xdat
and ydat
vectors.
The lookup method can use interpolation, extrapolation, or the original
values of the input.
Using the Lookup Table Dynamic block, you can change the table data without stopping the simulation. For example, you can incorporate new table data if the physical system you are simulating changes.
The xdat
vector is the breakpoint data, which
must be strictly monotonically increasing. The
value of the next element in the vector must be greater than the value
of the preceding element after conversion to a fixed-point data type.
Due to quantization, xdat
can be strictly monotonic
for a floating-point data type, but not after conversion to a fixed-point
data type.
The ydat
vector is the table data, which
is an evaluation of the function at the breakpoint values.
Note:
The inputs to |
You define the lookup table by feeding xdat
and ydat
as
1-by-n vectors to the block. To reduce ROM usage in the generated
code for this block, you can use different data types for xdat
and ydat
.
However, these restrictions apply:
The xdat
breakpoint data and the x
input
vector must have the same sign, bias, and fractional slope. Also,
the precision and range for x
must be greater than
or equal to the precision and range for xdat
.
The ydat
table data and the y
output
vector must have the same sign, bias, and fractional slope.
Tip:
Breakpoints with even spacing can make Simulink^{®} Coder™ generated
code division-free. For more information, see |
The block uses the input values to generate output using the method you select for Lookup Method:
Lookup Method | Block Action | |
---|---|---|
Interpolation-Extrapolation | Performs linear interpolation and extrapolation of the inputs.
| |
Interpolation-Use End Values (default) | Performs linear interpolation but does not extrapolate outside the end points of the breakpoint data. Instead, the block uses the end values. | |
Use Input Nearest | Finds the element in | |
Use Input Below | Finds the element in | |
Use Input Above | Finds the element in |
Note
The |
Some continuous solvers subdivide the simulation time span into major and minor time steps. A minor time step is a subdivision of the major time step. The solver produces a result at each major time step and uses results at minor time steps to improve the accuracy of the result at the major time step. For continuous solvers, the output of the Lookup Table Dynamic block can appear like a stair step because the signal is fixed in minor time step to avoid incorrect results. For more information about the effect of solvers on block output, see Solvers in the Simulink documentation.
The Lookup Table Dynamic block accepts signals of the following data types:
Floating point
Built-in integer
Fixed point
Boolean
For more information, see Data Types Supported by Simulink in the Simulink documentation.
Specify the lookup method. For details, see How the Block Generates Output.
Specify the output data type. You can set it to:
A rule that inherits a data type, for example, Inherit:
Inherit via back propagation
The name of a built-in data type, for example, single
The name of a data type object, for example, a Simulink.NumericType
object
An expression that evaluates to a data type, for example, fixdt('double')
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.
See Control Signal Data Types for more information.
Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).
Specify the rounding mode for fixed-point operations. For more information, see Rounding (Fixed-Point Designer). in the Fixed-Point Designer™ documentation.
Select to have overflows saturate to the maximum or minimum value that the data type can represent. Otherwise, overflows wrap.
When you select this check box, saturation applies to every internal operation on the block, not just the output or result. In general, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.
For an example of... | See... |
---|---|
Breakpoint and table data entry | Entering Data Using Inports of the Lookup Table Dynamic Block |
Block output for different lookup methods |
Data Types | Double | Single | Boolean | Base Integer | Fixed-Point |
Direct Feedthrough | Yes |
Multidimensional Signals | Yes |
Variable-Size Signals | No |
Zero-Crossing Detection | No |
Code Generation | Yes |