Engee documentation

Lookup Table Dynamic

Approximation of a univariate function using a dynamic table.

lookup table dynamic

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

Interpolation-Extrapolation

Performs linear interpolation and extrapolation of input data.

  • If the input data matches the reference point, the output data will be the corresponding item in the data table.

  • If the input data does not match the reference point, the block performs linear interpolation between the two items in the table to calculate the output data. If the input data is outside the range of the reference point values, the block extrapolates using the first two or the last two points.

Interpolation-Use End Values (By default).

Performs linear interpolation, but does not extrapolate beyond the end values of the reference points. Instead, the block uses the extreme values.

Use Input Nearest

Finds the nearest element in xdat to the current input value. The corresponding element in ydat is the output value.

Use Input Below

Finds the element in xdat nearest to the current input value and below it. The corresponding element in ydat is the output value. If there is no element in xdat below the current input value, the block finds the nearest element.

Use Input Above

Finds the element in xdat nearest to and above the current input value. The corresponding element in ydat is the output value. If there is no element in xdat above the current input value, the block finds the nearest element.

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

Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Bool, Fixed.

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

Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Bool, Fixed.

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

Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Bool, Fixed.

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

Float32, Float64, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Bool, Fixed.

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

Interpolation-Extrapolation | Interpolation-Use End Values | Use Input Nearest | Use Input Below | Use Input Above

Default value

Interpolation-Use End Values

Program usage name

LookUpMeth

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

Float64 | Float32 | Int8 | UInt8 | Int16 | UInt16 | Int32 | UInt32 | Int64 | UInt64 | Int128 | UInt128 | Bool | Fixed-point

Default value

Float64

Program usage name

OutDataTypeStr

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

fixdt(1, 16, 0)

Program usage name

OutDataTypeStrFixed

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

Ceiling | Convergent | Floor | Nearest | Round | Zero

Default value

Floor

Program usage name

RndMeth

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

false (switched off)

Program usage name

DoSatur

Tunable

No

Evaluatable

No