| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
Lookup Tables

The Direct Lookup Table (n-D) block uses its inputs as zero-based indices into an n-dimensional table. The number of inputs varies with the shape of the output, which can be an element, a column, or a 2-D matrix. The lookup table uses zero-based indexing, so integer data types can fully address their range. For example, a table dimension using the uint8 data type can address all 256 elements.
You define a set of output values as the Table data parameter. You specify what object the inputs select from the table: an element, a column, or a 2-D matrix. The first input specifies the zero-based index to the first dimension higher than the number of dimensions in the output, the next input specifies the index to the next table dimension, and so on:

The figure shows a 5-D table, and the output is a 2-D matrix with R rows and C columns. (See Changing a Block's Orientation in the Simulink documentation for a description of the port order for various block orientations.)
Depending on parameters you set in the block dialog box, the block icon changes appearance. For table dimensions higher than 4, the icon image matches the 4-D version but shows the exact number of dimensions in the top text.
| Block Icon | Block Parameter Settings | ||
|---|---|---|---|
| Number of table dimensions | Inputs select this object from table | Make table an input | |
| 1 | Element | Not selected |
| 1 | Element | Selected |
| 2 | Element | Not selected |
| 2 | Element | Selected |
| 2 | Column | Not selected |
| 2 | Column | Selected |
| 3 | Element | Not selected When you select this check box, you can use only 1-D or 2-D table data, because this block does not support multidimensional inputs. |
| 3 | Column | |
| 3 | 2-D Matrix | |
| 4 | Element | Not selected When you select this check box, you can use only 1-D or 2-D table data, because this block does not support multidimensional inputs. |
| 4 | Column | |
| 4 | 2-D Matrix | |
| 5 | Element | Not selected When you select this check box, you can use only 1-D or 2-D table data, because this block does not support multidimensional inputs. |
| 5 | Column | |
| 5 | 2-D Matrix | |
The Direct Lookup Table (n-D) block accepts signals of a numeric data type supported by Simulink software, but not fixed-point data types. For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink.
The output type can differ from the input type and can be any of the types listed for input. When the table data is not an input, the block inherits the output type from the data type of the Table data parameter. When the table data is an input, the block inherits the output type from the table input port. Inputs for indexing must be real, but table data can be complex.

The number of dimensions that the Table data parameter must have. This value determines the number of independent variables for the table and the number of inputs to the block. Options include: 1, 2 (default), 3, or 4. To specify a higher number of dimensions, enter a positive integer directly in the field.
Specify whether the output data is a single element, a column, or a 2-D matrix. The number of input ports for indexing depends on your selection.
| Selection | Number of Input Ports for Indexing |
|---|---|
| Element | Number of table dimensions |
| Column | Number of table dimensions - 1 |
| 2-D Matrix | Number of table dimensions - 2 |
This numbering matches MATLAB indexing. For example, if you have a 4-D table of data, follow these guidelines:
| To access... | Specify... | As in... |
|---|---|---|
| An element | Four indices | array(1,2,3,4) |
| A column | Three indices | array(:,2,3,4) |
| A 2-D matrix | Two indices | array(:,:,3,4) |
Selecting this check box forces the Direct Lookup Table (n-D) block to ignore the Table data parameter. Instead, a new input port appears with T next to it. Use this port to input table data.
The table of output values. The matrix size must match the dimensions of the Number of table dimensions parameter. During block diagram editing, you can leave the Table data field empty. But for simulation, you must match the number of dimensions in Table data to the Number of table dimensions. For details on how to construct multidimensional MATLAB arrays, see Multidimensional Arrays in the MATLAB documentation.
This parameter is available only if you clear the Make table an input check box.
Click Edit to open the Lookup Table Editor. For more information, see Lookup Table Editor in the Simulink documentation.
Specifies whether to produce a warning or error message when the input is out of range. Options include:
None — the default, which means no warning or error message
Warning — display a warning message in the MATLAB Command Window and continue the simulation
Error — halt the simulation and display an error message in the Simulation Diagnostics Viewer
The time interval between samples. To inherit the sample time, set this parameter to -1. See How to Specify the Sample Time in the Simulink documentation for more information.
In this example, the block parameters are:
Number of table dimensions: 4 Inputs select this object from table: "Column" Table data: int16(a)
where a is a 4-D array of linearly increasing numbers calculated with MATLAB functions.
a = ones(20,4,5,7); L = numel(a); a(1:L) = (1:L)';
The block output is the vector of 20 values in the second column, of the fourth element of the third dimension, from the third element of the fourth dimension.

The output has the same data type as the table, for example, int16. The block also uses zero-based indexing.
To calculate the output values manually, use the following MATLAB command (which uses one-based indexing):
a(:,1+1,1+3,1+2)
ans =
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
Direct Feedthrough | Yes |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | For scalar lookups only (not when returning a column or a 2-D matrix from the table) |
Dimensionalized | For scalar lookups only (not when returning a column or a 2-D matrix from the table) |
Multidimensionalized | No |
Zero-Crossing Detection | No |
![]() | Digital Clock | Discrete Derivative | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |