Simulink Reference    
Direct Look-Up Table (n-D)

Index into an N-dimensional table to retrieve a scalar, vector, or 2-D matrix

Library

Look-Up Tables

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 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 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 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.

Example

In this example, the block parameters are defined as

where a is a 4-D array of linearly increasing numbers calculated using MATLAB.

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 block uses zero-based indexing. The output values in this example can be calculated manually in MATLAB (which uses 1-based indexing):

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

Number of table dimensions

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," following).

Inputs select this object from table
Specify whether the output data is a single element, an n-D 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's 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).
Make table an input
Selecting this box forces the Direct Look-Up 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.

Table data

The table of output values. 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 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, see Multidimensional Arrays in MATLAB's online documentation. (This field appears only if Make table an input is not selected.)
Action for out of range input
None, Warning, Error.
Real-Time Workshop Note: in the generated code, the "Clip and Warn" and "Clip Index" options cause the Real-Time Workshop to generate clipping code with no code included to generate warnings. Code generated for the other option, "Generate Error", has no clipping code or error messages at all, on the assumption that simulation during the design phase of your project should reveal model defects leading to out-of-range cases. This assumption helps the code generated by the Real-Time Workshop to be highly efficient.

Characteristics

Direct Feedthrough
Yes
Sample Time
Inherited from driving blocks
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 Filter