This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Lookup Table Dynamic

Approximate a one-dimensional function using dynamic table

  • Library:
  • Simulink / Lookup Tables

Description

How This Block Differs from Other Lookup Table Blocks

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.

Inputs for Breakpoint and Table Data

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 xdat and ydat cannot be scalar (one-element array) values. If you provide a scalar value to either of these inputs, you see an error upon simulation. Provide a 1-by-n vector to both the xdat and ydat inputs.

Lookup Table Definition

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 fixpt_evenspace_cleanup in the Simulink documentation and Identify questionable fixed-point operations (Embedded Coder) in the Simulink Coder documentation.

How the Block Generates Output

The block uses the input values to generate output using the method you select for Lookup Method:

Lookup MethodBlock Action
Interpolation-Extrapolation

Performs linear interpolation and extrapolation of the inputs.

  • If the input matches a breakpoint, the output is the corresponding element in the table data.

  • If the input does not match a breakpoint, the block performs linear interpolation between two elements of the table to determine the output. If the input falls outside the range of breakpoint values, the block extrapolates using the first two or last two points.

Note

If you select this lookup method, Simulink Coder software cannot generate code for this block.

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 xdat nearest the current input. The corresponding element in ydat is the output.

Use Input Below

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

Use Input Above

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

Note

The Use Input Nearest, Use Input Below, and Use Input Above methods perform the same action when the input x matches a breakpoint value.

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.

Ports

Input

expand all

The block accepts real-valued or complex-valued multidimensional inputs.

Example: 2:12

Dependencies

The x input vector and the xdat breakpoint data 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.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | bus

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.

Tip

Breakpoints with even spacing can make Simulink Coder generated code division-free. For more information, see fixpt_evenspace_cleanup in the Simulink documentation and Identify questionable fixed-point operations (Embedded Coder) in the Simulink Coder documentation.

Example: 1:10

Dependencies

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.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | bus

The ydat input is a 1-by-n vector of real-valued or complex-valued table data, which is an evaluation of the function at the breakpoint values.

Example: [0 3 12 27 48 75 108 147 192 243 300]

Dependencies

The ydat table data and the y output vector must have the same sign, bias, and fractional slope.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | bus

Output

expand all

The block computes an approximation of a function y = f(x) using the xdat and ydat input vectors. The lookup method can use interpolation, extrapolation, or the original values of the input.

Dependencies

The ydat table data and the y output vector must have the same sign, bias, and fractional slope.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point

Parameters

expand all

Main Tab

The block computes output by applying the Lookup Method you select to the input vectors of breakpoint data (xdat) and table data (ydat). For details, see How the Block Generates Output.

Programmatic Use

Block Parameter: LookUpMeth
Type: character vector
Values: 'Interpolation-Extrapolation' | 'Interpolation-Use End Values' | 'Use Input Nearest' | 'Use Input Below' | 'Use Input Above'
Default: 'Interpolation-Use End Values'

Signal Attributes Tab

Specify the data type of the output signal y.

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant.

Dependencies

The ydat table data and the y output vector must have the same sign, bias, and fractional slope.

Programmatic Use

Block Parameter: OutDataTypeStr
Type: character vector
Values: 'Inherit: Inherit via back propagation' | 'double' | 'single' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'int64' | 'uint64' | 'boolean' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)'|<data type expression>
Default: 'double'

Select this parameter to prevent the fixed-point tools from overriding the Output data type you specify on the block. For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).

Programmatic Use

Block Parameter: LockScale
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Specify the rounding mode for fixed-point operations. For more information, see Rounding (Fixed-Point Designer).

Block parameters always round to the nearest representable value. To control the rounding of a block parameter, enter an expression using a MATLAB® rounding function into the mask field.

Programmatic Use

Block Parameter: RndMeth
Type: character vector
Values: 'Ceiling' | 'Convergent' | 'Floor' | 'Nearest' | 'Round' | 'Simplest' | 'Zero'
Default: 'Floor'

When you select this check box, 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.

Programmatic Use

Block Parameter: DoSatur
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Block Characteristics

Data Types

Boolean | double | fixed point | integer | single

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
Convert floating-point algorithms to fixed point using Fixed-Point Designer™.

Introduced before R2006a