Simulink Reference |
 |
Look-Up Table (n-D)
Perform constant, linear, or spline interpolated mapping of N input values to a sampled representation of a function in N variables.
Library
Look-Up Tables
Description

The Look-Up Table (n-D) block evaluates a sampled representation of a function in N variables by interpolating between samples to give an approximate value for
, even when the function F is known only empirically. The block efficiently maps the block inputs to the output value using interpolation on a table of values defined by the block's parameters. Interpolation methods supported are
- Flat (constant)
- Linear
- Natural (cubic) spline
You can apply any of these methods to 1-D, 2-D, 3-D, or higher dimensional tables.
You define a set of output values as the Table data parameter and the values that correspond to its rows, columns, and higher dimensions with the Nth breakpoint set parameter. The block generates an output value by comparing the block inputs with the breakpoint set parameters. The first input identifies the first dimension (row) breakpoints, the second breakpoint set identifies a column, and so on, as shown by this figure.
If you are unfamiliar with how to construct N-dimensional arrays in MATLAB, see Multidimensional Arrays in MATLAB's online documentation.
The block generates output based on the input values:
- If the inputs match breakpoint parameter values, the output is the table value at the intersection of the row, column, and higher dimensions breakpoints.
- If the inputs do not match row and column parameter values, the block generates output by interpolating between the appropriate table values. If any of the block inputs are outside the ranges of their respective breakpoint sets, the block limits the input values to the breakpoint set's range in that dimension. If extrapolation is enabled, it extrapolates linearly or by using a cubic polynomial (if you selected cubic spline extrapolation).
Note As an alternative, you can use the Look-Up Table (n-D) block with the PreLook-Up Index Search block to have more flexibility and potentially much higher performance for linear interpolations in certain circumstances.
For noninterpolated table lookups, use the Direct Look-Up Table (n-D) block when the lookup operation is a simple array access, for example, if you have an integer value k
and you merely want the k
th element of a table, y = table(k).
Data Type Support
A Look-Up Table (n-D) block accepts signals of types double
or single
, but for any given Look-Up Table (n-D) block, the inputs must all be of the same type. Table data and Breakpoint set parameters must be of the same type as the inputs. The output data type is also set to the input data type.
Parameters and Dialog Box

- Number of table dimensions
- The number of dimensions that the Table data parameter is to have. This determines the number of independent variables for the table and hence the number of inputs to the block (see descriptions for "Explicit Number of dimensions" and "Use one (vector) input port instead of N ports", following).
- First input (row) breakpoint set
- The row values represented in the table, entered as a vector. The vector values must increase monotonically. This field is always visible.
- Second (column) input breakpoint set
- The column values for the table, entered as a vector. The vector values must increase monotonically. This field is visible if the Number of table dimensions value is 2, 3, 4, or More.
- Third ... Nth input breakpoint set
- The values corresponding to the third dimension for the table, entered as a vector. The vector values must increase monotonically. This field is visible if the Number of table dimensions is 3, 4, or More.
- Fourth input breakpoint set
- The values corresponding to the fourth dimension for the table, entered as a vector. The vector values must increase monotonically. This field is visible if the Number of table dimensions is 4 or More.
- Fifth..Nth input breakpoint sets (cell array)
- The cell array of values corresponding to the third, fourth, or higher dimensions for the table, entered as a 1-D cell array of vectors. For example,
{[10:10:30], [0:10:100]}
is a cell array of two vectors that are used for the fifth and sixth dimensions' breakpoint sets. The vector values must increase monotonically. This field is visible if the Number of table dimensions is More.
- Explicit number of dimensions
- The number of table dimensions when the number is
5
or more. This is indicated when you set the Number of table dimensions field to More
.
- Index search method
- Choose
Evenly Spaced Points
, Linear Search
, or Binary Search
(the default). Each search method has speed advantages over the others in different circumstances. A suboptimal choice of index search method can lead to slow performance in models that rely heavily on lookup tables. If the breakpoint data is evenly spaced, e.g., 10, 20, 30, ..., you can achieve the greatest speed by selecting Evenly Spaced Points
to directly calculate the indices into the table. For irregularly spaced breakpoint sets, if the input signals do not vary much from one time step to the next, selecting Linear Search
and Begin index searches using previous index results
at the same time will produce the best performance. For irregularly spaced breakpoint sets with rapidly varying input signals that jump more than one or two table intervals per time step, selecting Binary Search
gives the best performance. Note that the Evenly Spaced Points
algorithm only makes use of the first two breakpoints in determining the offset and spacing of the rest of the points.
- Begin index searches using previous index results
- Activating this option causes the block to initialize index searches using the index found on the previous time step. This is a huge performance improvement for the block when the input signals do not change much with respect to its position in the table from one time step to the next. When this option is deactivated, the linear search and binary search methods can take significantly longer, especially for large breakpoint data sets.
- Use one (vector) input port instead of N ports
- Instead of having one input port per independent variable, the block is configured with just one input port that expects a signal that is N elements wide for an N-dimensional table. This might be useful in removing line clutter on a block diagram with large numbers of tables.
- Table data
- The table of output values. To execute a model with this block, the matrix size must match the dimensions defined by the N breakpoint set parameter or by the Explicit number of dimensions parameter when the number of dimensions exceeds
4
. During block diagram editing, you can leave this field blank because only the Number of table dimensions field is required to set the number of ports on the block.
- Interpolation method
- None (flat), Linear, or Cubic Spline.
- Extrapolation method
- None (clip), Linear, or Cubic Spline.
- Action for out of range input
- None, Warning, or Error. An out-of-range condition during simulation results in warning messages in the command window if "Warning" is selected, and the simulation halts with an error message if "Error" is selected.
Characteristics
Direct Feedthrough
|
Yes
|
Sample Time
|
Inherited from driving blocks
|
Scalar Expansion
|
No
|
Dimensionalized
|
No
|
Zero Crossing
|
No
|
| Look-Up Table (2-D) | | Magnitude-Angle to Complex |  |