| Simulink® | ![]() |
Index into N-dimensional table to retrieve element, column, or 2-D matrix
Lookup Tables

The Direct Lookup Table (n-D) block uses its block inputs as zero-based indices into an n-D table. The number of inputs varies with the shape of the output desired. The output 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, as shown by this figure:

The figure shows a 5-D table with an output shape set to "2-D Matrix"; the output is a 2-D Matrix with R rows and C columns. (See Changing the Orientation of a Blockin the Simulink® documentation for a description of the port order for various block orientations.)
This figure shows the set of all the different icons that the Direct Lookup Table block shows (depending on the options you choose in the block's dialog box).
![]()
With dimensions higher than 4, the icon matches the 4-D icons, but shows the exact number of dimensions in the top text, e.g., "8-D T[k]." The top row of icons is used when the block output is made from one or more single-element lookups on the table. The blocks labeled "n-D Direct Table Lookup5," 6, 8, and 12 are configured to extract a column from the table, and the two blocks ending in 7 and 9 are extracting a plane from the table. Blocks in the figure ending in 10, 11, and 12 are configured to have the table be an input instead of a parameter.
In this example, the block parameters are defined as
Inputs select this object from table: "Column" Table data: int16(a)
where a is a 4-D array of linearly increasing numbers calculated using MATLAB® functions.
a = ones(20,4,5,7); L = prod(size(a)); a(1:L) = [1:L]';
The figure shows the block outputting a vector of the 20 values in the second column of the fourth element of the third dimension from the third element of the fourth dimension.

Note that the output has the same data type as the table, i.e., int16. Also note that the block uses zero-based indexing. The output values in this example can be calculated manually using the following MATLAB command (which uses 1-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
The Direct Lookup Table (n-D) block accepts mixed-type signals of data type supported by Simulink software. 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; the output type is inherited from the data type of the Table data parameter.
In the case that the table comes into the block on an input port, the output port type is inherited from the table input port. Inputs for indexing must be real; table data can be complex.

The number of dimensions that the Table data parameter must have. This determines the number of independent variables for the table and hence the number of inputs to the block. The options are 1, 2, 3, 4, or More dimensions. If you choose More, the dialog box displays an edit field, Explicit number of table dimensions, that allows you to enter a number of dimensions.
This field appears if you select more as the value of the Number of table dimensions. Enter the number of table dimensions in this field.
Specify whether the output data is a single element, a column, or a 2-D matrix. The number of ports changes for each selection:
Element — # of ports = # of dimensions
Column — # of ports = # of dimensions - 1
2-D matrix — # of ports = # of dimensions - 2
This numbering agrees with MATLAB indexing. For example, if you have a 4-D table of data, to access a single element you must specify four indices, as in array(1,2,3,4). To specify a column, you need three indices, as in array(:,2,3,4). Finally, to specify a 2-D matrix, you only need two indices, as in array(:,:,3,4).
Selecting this box forces the Direct Lookup Table (n-D) block to ignore the Table Data parameter. Instead, a new 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 defined by the Number of table dimensions parameter or by the Explicit number of dimensions parameter when the number of dimensions exceeds four. During block diagram editing, you can leave the Table data field empty, but for running the simulation, you must match the number of dimensions in the Table data to the Number of table dimensions. For information about how to construct multidimensional arrays in MATLAB software, see Multidimensional Arrays in the MATLAB online documentation. (This field appears only if Make table an input is not selected.)
None, Warning, Error.
The time interval between samples. To inherit the sample time, set this parameter to -1. See Specifying Sample Time in the Simulink documentation for more information.
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) |
Zero Crossing | No |
![]() | Digital Clock | Discrete Derivative | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |