Lookup Table (2-D) (Obsolete)
Approximate two-dimensional function
Library
Lookup Tables (until R2010b)
Description
Note
The Lookup Table (2-D) block is obsolete. This block was removed from the Lookup Tables library in R2011a and replaced with a 2-D version of the n-D Lookup Table block. However, existing models that contain the Lookup Table (2-D) block continue to work for backward compatibility.
Use the 2-D Lookup Table block in new
models. Consider using the upgradeadvisor
function to replace
Lookup Table (2-D) with 2-D Lookup Table in existing models. See Programmatically Analyze and Upgrade Model.
Among other enhancements, the 2-D Lookup Table block supports the following features that the Lookup Table (2-D) block does not:
Specification of parameter data types different from input or output signal types
Reduced memory use and faster code execution for evenly-spaced breakpoints that are nontunable
Fixed-point data types with word lengths up to 128 bits
Specification of index search method
Specification of diagnostic for out-of-range inputs
For more information, see Update Lookup Table Blocks to New Versions.
How the Block Differs from Other Lookup Table Blocks
The Lookup Table (2-D) block computes an approximation
to a function z = f(x,y)
given x
, y
, z
data
points. The first input port maps to the first table dimension, x
,
and the second input port maps to the second table dimension, y
.
You define the lookup table by specifying:
Row index input values as a
1-by-m
vector ofx
data pointsColumn index input values as a
1-by-n
vector ofy
data pointsTable data as an
m-by-n
matrix ofz
data points
To avoid parameter saturation errors, the Fixed-Point Designer™ automatic
scaling script employs a special rule for the Lookup Table
(2-D) block. autofixexp
(Fixed-Point Designer) modifies
the scaling by using the lookup values of the Table data parameter
in addition to the logged minimum and maximum simulation values. These
table data values are converted to the specified output data type.
This action prevents saturation of the data to different values.
Monotonicity Requirements
Both the row and column vectors must be monotonically increasing. In other words, the value of the next element in the vector is greater than or equal to the value of the preceding element. However, these vectors must be strictly monotonically increasing (the value of the next element in the vector is greater than the value of the preceding element) in the following cases:
The input and output data types are both fixed-point.
The input and output data types are different.
The lookup method is not
Interpolation-Extrapolation
.The matrix of output values is complex.
Minimum, maximum, and overflow logging is on.
Tip
Evenly-spaced breakpoints can make the generated code division-free.
For more information, see fixpt_evenspace_cleanup
and Identify questionable fixed-point operations (Embedded Coder).
For more information about monotonicity requirements, see Characteristics of Lookup Table Data. For information about creating a table with step transitions, see Representation of Discontinuities in Lookup Tables.
How the Block Generates Output
The block uses the input values to generate output using the method you select for the Lookup method parameter:
Lookup Method | Action by the Block |
---|---|
Interpolation-Extrapolation (default) | Performs linear interpolation and extrapolation of the inputs.
Note If you select this lookup method, code generation can occur for this block only if the input and output signals have the same floating-point data type. |
Interpolation-Use End Values | Performs linear interpolation but does not extrapolate
outside the end points of |
Use Input Nearest | Finds the elements in |
Use Input Below | Finds the elements in |
Use Input Above | Finds the elements in |
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.
Data Type Support
The Lookup Table (2-D) block supports the following data types:
Floating point
Built-in integer
Fixed point
Boolean
For more information, see Data Types Supported by Simulink.
Parameters
- Row index input values
Specify the row values for the table as a vector. The vector values must increase monotonically.
The Row index input values parameter is converted offline to the data type of the corresponding input signal using round-to-nearest and saturation.
- Column index input values
Specify the column values for the table as a vector. The vector values must increase monotonically.
The Column index input values parameter is converted offline to the data type of the corresponding input signal using round-to-nearest and saturation.
Click the Edit button to open the Lookup Table Editor (see Edit Lookup Tables).
- Table data
Specify the table of output values as a matrix. The matrix size must match the dimensions of the Row and Column parameters.
The Table data parameter is converted offline to the Output data type using round-to-nearest and saturation.
- Lookup method
Specify the lookup method. See How the Block Generates Output for a discussion of the options for this parameter.
- Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample time, set this parameter to
-1
. See Specify Sample Time for more information.
- Output minimum
Specify the minimum value that the block should output. The default value,
[]
, is equivalent to-Inf
. Simulink® software uses this value to perform:Parameter range checking (see Specify Minimum and Maximum Values for Block Parameters)
Simulation range checking (see Specify Signal Ranges)
Automatic scaling of fixed-point data types
- Output maximum
Specify the maximum value that the block should output. The default value,
[]
, is equivalent toInf
. Simulink software uses this value to perform:Parameter range checking (see Specify Minimum and Maximum Values for Block Parameters)
Simulation range checking (see Specify Signal Ranges)
Automatic scaling of fixed-point data types
- Require all inputs to have the same data type
Select to require all inputs to have the same data type.
- Output data type
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
objectAn expression that evaluates to a data type, for example,
fixdt(1,16,0)
Click the Show data type assistant button
to display the Data Type Assistant, which helps you set the Output data type parameter.
See Control Data Types of Signals for more information.
- Lock output data type setting against changes by the fixed-point tools
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 Fixed-Point Tool (Fixed-Point Designer).
- Integer rounding mode
Select the rounding mode for fixed-point lookup table calculations that occur during simulation or execution of code generated from the model. For more information, see Rounding (Fixed-Point Designer).
Block parameters such as Table data always round to the nearest representable integer value. To control the rounding of a block parameter, enter an expression using a MATLAB® rounding function into the parameter's edit field on the block dialog box.
- Saturate on integer overflow
Select to have overflows saturate. Otherwise, they 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 which case, no saturation code is necessary.
Examples
In this example, the block parameters are:
Row index input values: [1 2] Column index input values: [3 4] Table data: [10 20; 30 40]
The first figure shows the block outputting a value at the intersection of block inputs that match row and column values. The first input is 1 and the second input is 4. These values select the table value at the intersection of the first row (row parameter value 1) and second column (column parameter value 4).
In the second figure, the first input is 1.7 and the second is 3.4. These values cause the block to interpolate between row and column values, as shown in the table at the left. The value at the intersection (28) is the output value.
Characteristics
Direct Feedthrough | Yes |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes, of one input if the other is a vector |
Dimensionalized | Yes |
Zero-Crossing Detection | No |