Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Direct Lookup Table (n-D) - Index into N-dimensional table to retrieve element, column, or 2-D matrix

Library

Lookup Tables

Description

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

Changes in Block Icon Appearance

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 IconBlock Parameter Settings
Number of table dimensionsInputs select this object from tableMake table an input

1Element

Not selected

1Element

Selected

2Element

Not selected

2Element

Selected

2Column

Not selected

2Column

Selected

3Element

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.

3Column

32-D Matrix

4Element

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.

4Column

42-D Matrix

5Element

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.

5Column

52-D Matrix

Data Type Support

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.

Parameters and Dialog Box

Number of table dimensions

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.

Inputs select this object from table

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.

SelectionNumber of Input Ports for Indexing
ElementNumber of table dimensions
ColumnNumber of table dimensions - 1
2-D MatrixNumber 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 elementFour indicesarray(1,2,3,4)
A columnThree indicesarray(:,2,3,4)
A 2-D matrixTwo indicesarray(:,:,3,4)

Make table an input

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.

    Tip   If you select this check box, use only 1-D or 2-D table data, because this block does not support multidimensional inputs.

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.

Action for out-of-range input

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

Sample time (-1 for inherited)

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.

Examples

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

Characteristics

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

See Also

Lookup Table (n-D)

  


Related Products & Applications

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