Lookup Table Dynamic
Approximation of a univariate function using a dynamic table.
Description
Block Lookup Table Dynamic calculates the approximation of the function using the vectors xdat
and ydat
. The search method can use interpolation, extrapolation or the original values of the input data.
Read more about interpolation and extrapolation methods here: Methods of approximation of function values
Using block *Lookup Table Dynamic*you can change the table data without stopping the simulation. For example, you can add new data to the table if the physical system being modelled changes.
Input data for reference points and table data
The xdat
vector is a vector containing the values of the anchor points, which must be strictly monotonically increasing.
The ydat
vector is the table data, which represents the value of the function at the anchor points.
The input data xdat and ydat cannot be a scalar (single element array). If you enter a scalar value for either of them, the simulation will display an error message.
|
Defining a lookup table
The lookup table is defined by specifying the input vectors xdat
and ydat
. To reduce memory usage in the generated code for this block, you can use different data types for xdat
and ydat
.
How the block calculates the output data
The block uses the input values to calculate the output data, using the method that is selected in the parameters Lookup Method:
Parameters value Lookup Method | Block action |
---|---|
|
Performs linear interpolation and extrapolation of input data.
|
|
Performs linear interpolation, but does not extrapolate beyond the end values of the reference points. Instead, the block uses the extreme values. |
|
Finds the nearest element in |
|
Finds the element in |
|
Finds the element in |
Methods Use Input Nearest , Use Input Below и Use Input Above perform the same action when the values of the input vector x coincide with the values of the reference points.
|
Ports
Input
#
x
—
input vector
scalar
| vector
| dimensional matrix
Details
Real input signal.
The input vector x
and the reference vector xdat
must be of the same type in sign, offset and fractional slope. In addition, the precision and range for the x
data type must be greater than or equal to the precision and range for xdat
.
Data types |
|
Complex numbers support |
Yes |
#
xdat
—
vector of reference point values
vector of strictly monotonically increasing values of dimension 1 over n
| matrix
Details
The vector xdat
is a vector containing the values of the reference points, which must be strictly monotonically increasing.
The input vector x
and the reference point vector xdat
must be of the same type in sign, offset and fractional slope. In addition, the precision and range for the x
data type must be greater than or equal to the precision and range for xdat
.
Data types |
|
Complex numbers support |
Yes |
#
ydat
—
tabular data
`vector of dimension 1 by n
Details
A ydat
vector is a vector of dimension 1 on of real or complex tabular data, which represent the value of a function at reference points.
Data types |
|
Complex numbers support |
Yes |
Output
#
y
—
approximation of y = f(x) using a dynamic table
vector of dimension 1 by n
| scalar
Details
Function approximation using input vectors of reference points xdat
and tabular data ydat
. The search method can use interpolation, extrapolation or the original values of the input data.
Data types |
|
Complex numbers support |
Yes |
Parameters
Main
#
Lookup Method —
search method
Interpolation-Extrapolation
| Interpolation-Use End Values
| Use Input Nearest
| Use Input Below
| Use Input Above
Details
The block calculates the output data by applying the selected method Lookup Method to the input vectors of reference points xdat
and table data ydat
. See How the block calculates output data for details.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
Signal Attributes
#
Output data type —
output data type
Float64
| Float32
| Int8
| UInt8
| Int16
| UInt16
| Int32
| UInt32
| Int64
| UInt64
| Int128
| UInt128
| Bool
| Fixed-point
Details
Specify the type of output data.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
#
Output fixed-point type —
fixed-point output data type
Data type
Details
Specify the type of fixed-point output data.
Dependencies
To use this parameter, set the parameters to Output data type value Fixed-point
.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
#
Integer rounding mode —
rounding mode for fixed-point operations
Ceiling
| Convergent
| Floor
| Nearest
| Round
| Zero
Details
Select the rounding mode for fixed point operations. You can select:
-
Floor
- rounds both positive and negative numbers downwards (towards negative infinity). -
Ceiling
- rounds both positive and negative numbers upwards (towards positive infinity). -
Convergent
- rounds the number to the nearest representable value. If the fractional part of a number ends in 5, the number is rounded to the nearest even integer. -
Nearest
- rounds the number to the nearest representable value. If the fractional part of the number ends in 5, the number is rounded upwards (towards positive infinity). -
Round
- rounds the number to the nearest representable value. If the fractional part of a number ends in 5, positive numbers are rounded upwards (towards positive infinity) and negative numbers are rounded downwards (towards negative infinity).
-
Zero
- rounds the number towards zero.
The block parameters are always rounded to the nearest representable value.
Values |
|
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |
#
Saturate to max or to min when overflows occur —
saturation to integer in case of overflow
Logical
Details
When checked, overflows are saturated to the maximum or minimum value that can be represented by the given data type. Otherwise, overflows are wrapped around to the appropriate value that the data type can represent.
When this check box is selected, saturation is applied to all internal block operations, not just the output or result.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
No |