| Contents | Index |
Lookup Tables
The Direct Lookup Table (n-D) block uses inputs as zero-based indices into an n-dimensional table. The number of inputs varies with the shape of the output: an element, column, or 2-D matrix.
You define a set of output values as the Table data parameter. The first input specifies the zero-based index to the table dimension that is one higher than the output dimensionality. The next input specifies the zero-based index to the next table dimension, and so on.
| Output Shape | Output Dimensionality | Table Dimension That Maps to the First Input |
|---|---|---|
| Element | 0 | 1 |
| Column | 1 | 2 |
| Matrix | 2 | 3 |
Suppose that you want to select a column of values from a 4-D table:

The following mapping of block input port to table dimension applies:
| This input port... | Is the index for this table dimension... |
|---|---|
| 1 | 2 |
| 2 | 3 |
| 3 | 4 |
Depending on parameters you set, the block icon changes appearance. For table dimensions higher than 4, the icon matches the 4-D version but shows the exact number of dimensions in the top text.
When you use the Table data parameter, you see the following icons:
| Object That Inputs Select from the Table | Number of Table Dimensions | |||
|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |
Element |
|
|
|
|
Column |
|
|
|
|
2-D Matrix | Not applicable |
|
|
|
When you use the table input port, you see the following icons:
| Object That Inputs Select from the Table | Number of Table Dimensions | |||
|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |
Element |
|
|
|
|
Column |
|
|
|
|
2-D Matrix | Not applicable |
|
|
|
The Direct Lookup Table (n-D) block accepts input signals of different data types.
| Type of Input Port | Data Types Supported |
|---|---|
| Index port |
|
| Table port (with the label T) |
|
The output data type is the same as the table data type. Inputs for indexing must be real, but table data can be complex.
| When the table data is... | The block inherits the output type from... |
|---|---|
| Not an input | The Table data type parameter |
| An input | The table input port |
For more information, see Data Types Supported by Simulink in the Simulink documentation.
The Main pane of the Direct Lookup Table (n-D) block appears as follows:

Specify 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.
| To specify... | Do this... |
|---|---|
1, 2, 3, or 4 | Select the value from the drop-down list. |
A higher number of table dimensions | Enter a positive integer directly in the field. The maximum number of table dimensions that this block supports is 30. |
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) |
Select this check box to force 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.
Specify the table of output values. The matrix size must match the dimensions of the Number of table dimensions parameter. The Table data field is available only if you clear the Make table an input check box.
Tip 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. |
Click Edit to open the Lookup Table Editor. For more information, see Lookup Table Editor in the Simulink documentation.
Specify whether to show a warning or error when an index is out of range with respect to the table dimension. Options include:
None — do not display any 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
When you select None or Warning, the block clamps out-of-range indices to fit table dimensions. For example, if the specified index is 5.3 and the maximum index for that table dimension is 4, the block clamps the index to 4.
Specify 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.
The Table Attributes pane of the Direct Lookup Table (n-D) block appears as follows:

Note The parameters in the Table Attributes pane are not available if you select Make table an input. In this case, the block inherits all table attributes from the input port with the label T. |
Specify the minimum value for table data. The default value is [] (unspecified).
Specify the maximum value for table data. The default value is [] (unspecified).
Specify the table data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit from 'Table data'
The name of a built-in data type, for example, single
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Table
data type parameter.
Select to lock all data type settings of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, see Fixed-Point Tool and Fixed-Point Advisor in the Simulink Fixed Point documentation.
Suppose that you have the following model:

The Direct Lookup Table (n-D) block parameters are:
| Block Parameter | Value |
|---|---|
| Number of table dimensions | 4 |
| Inputs select this object from table | Column |
| Make table an input | off |
| Table data | a |
| Diagnostic for out-of-range input | Warning |
| Sample time | –1 |
| Table minimum | [] |
| Table maximum | [] |
| Table data type | int16 |
| Lock data type settings against changes by the fixed-point tools | off |
In this example, a is a 4-D array of linearly increasing values that you define with the following model preload function:
a = reshape(1:2800, [4 5 20 7]);
When you run the model, you get the following results:

Because the Direct Lookup Table (n-D) block uses zero-based indexing, the output is:
a(:,2,4,3)
The output has the same data type as the table: int16.
Suppose that you have the following model:

The Direct Lookup Table (n-D) block parameters are:
| Block Parameter | Value |
|---|---|
| Number of table dimensions | 4 |
| Inputs select this object from table | Column |
| Make table an input | on |
| Diagnostic for out-of-range input | Warning |
| Sample time | –1 |
The key parameters of the Constant3 block are:
| Block Parameter | Value |
|---|---|
| Constant value | a |
| Output data type | fixdt(1,16,2) |
In this example, a is a 4-D array of linearly increasing values that you define with the following model preload function:
a = reshape(1:2800, [4 5 20 7]);
When you run the model, you get the following results:

The Constant3 block feeds the 4-D array to the Direct Lookup Table (n-D) block, using the fixed-point data type fixdt(1,16,2). Because the Direct Lookup Table (n-D) block uses zero-based indexing, the output is:
a(:,2,4,3)
The output has the same data type as the table: fixdt(1,16,2).
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 | Yes |
Zero-Crossing Detection | No |

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