Using Simulink | ![]() ![]() |
Index into an N-dimensional table to retrieve a scalar, vector or 2-D matrix.
Library
Description
The Direct Look-Up 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 a scalar, a vector, or a 2-D matrix. The look-up table uses zero-based indexing, so integer datatypes 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 the output shape is: a scalar, a vector 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 second 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.
This figure shows the set of all the different icons that the Direct Look-Up Table block shows (depending on which options you choose in the block's dialog box).
With dimensions higher than 4, the icon matches the 4-D icons, but will show 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 labelled "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.
Example
In this example, the block parameters are defined as
Invalid input value: "Clip and Warn" Output shape: "Vector" Table data: int16(a)
where a is a 4-D array of linearly increasing numbers calculated using MATLAB.
a = ones(20,4,5,7); L = prod(size(a)); a(1:L) = [1:L]';
Remembering that the table indices are zero-based, 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.
The output values in this example can be calculated manually in MATLAB (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
Data Type
Support
The Direct Look-Up Table (n-D) block accepts mixed-type signals of type double
, single
, int8
, uint8
, int16
, uint16
, int32
and, uint32
. 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.
Dialog Box
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 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 (see descriptions for "Explicit Number of dimensions" and "Use one (vector) input port instead of N ports," below).
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)
.Characteristics
![]() | Digital Clock | Discrete Filter | ![]() |