Using Simulink |
 |
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
Functions & 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 will limit 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 non-interpolated table look-ups, use the Direct Look-Up Table, (n-D) block when the look-up 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
An n-D Interpolated Look-Up Table block accepts signals of types double
or single
, but for any given n-D Interpolated Look-Up Table 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", below).
- 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 popup 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 will be 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 five or more. This is indicated when you set the Numbor of table dimensions field to More.
- Index search method
- Choose "Evenly Spaced Points", "Linear Search" or "Binary Search" (default). Each search method has speed advantages over the others in different circumstances. A suboptimal choice of index seach method can lead to slow performance in models that rely heavily on look-up tables. If the breakpoint data are 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 speed 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" will give the best speed 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 will cause 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 may 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 four. During block diagram ediig, you can leave this field blank since 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 |  |