| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
Lookup Tables

The Lookup Table (n-D) block evaluates a sampled representation
of a function in N variables
, where the function F can
be empirical. The block maps inputs to an output value by looking
up or interpolating a table of values you define with block parameters.
The block supports flat (constant), linear, and cubic-spline interpolation
methods. You can apply these methods to a table of any dimension from
1 through 30.
In the following block, the first input identifies the first dimension (row) breakpoints, the second input identifies the second dimension (column) breakpoints, and so on.

See How to Rotate a Block for a description of the port order for various block orientations.
The following block parameters define the breakpoint and table data.
| Block Parameter | Purpose |
|---|---|
| Number of table dimensions | Specifies the number of dimensions of your lookup table. |
| Table and Breakpoints (BP) > BP | Specifies a breakpoint vector that corresponds to each dimension of your lookup table. |
| Table and Breakpoints (BP) > Table | Defines the associated set of output values. |
Tip Evenly-spaced breakpoints can make Real-Time Workshop generated code division-free. For more information, see fixpt_evenspace_cleanup in the Simulink documentation and Identify questionable fixed-point operations in the Real-Time Workshop documentation. |
The Lookup Table (n-D) block generates output by looking up or estimating table values based on the input values:
| If the inputs... | The Lookup Table (n-D) block... |
|---|---|
| Match the values of indices in breakpoint data sets | Outputs the table value at the intersection of the row, column, and higher dimension breakpoints |
| Do not match the values of indices in breakpoint data sets, but are within range | Interpolates appropriate table values, using the Interpolation method you select |
| Do not match the values of indices in breakpoint data sets, and are out of range | Extrapolates the output value, using the Extrapolation method you select |
You can use the Interpolation Using Prelookup block with the Prelookup block to perform the equivalent operation of a Lookup Table (n-D) block. This combination of blocks offers greater flexibility that can result in more efficient simulation performance for linear interpolations in certain circumstances.
When the lookup operation is a simple array access that does not require interpolation, use the Direct Lookup Table (n-D) block. For example, if you have an integer value k and you want the kth element of a table, y = table(k), interpolation is unnecessary.
The Lookup Table (n-D) block supports all numeric data types supported by Simulink software, including fixed-point data types. For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink in the Simulink documentation.
Inputs for indexing must be real, but table data can be complex.
The Table and Breakpoints pane of the Lookup Table (n-D) block dialog box appears as follows:

Enter the number of dimensions of the lookup table by specifying an integer from 1 to 30. This parameter determines:
The number of independent variables for the table and the number of block inputs
The number of breakpoint sets to specify in Table and Breakpoints (BP)
In the Table row, enter the table of output values.
Tip During simulation, the matrix size must match the dimensions defined by the Number of table dimensions parameter. However, during block diagram editing, you can enter an empty matrix (specified as []) or an undefined workspace variable. This technique lets you postpone specifying a correctly dimensioned matrix for the table data and continue editing the block diagram. For information about how to construct multidimensional arrays in MATLAB software, see Multidimensional Arrays in the MATLAB online documentation. |
In each BP row, enter the breakpoint set that corresponds to each dimension of table data. For each dimension, specify breakpoints as a 1-by-n or n-by-1 vector whose values are strictly monotonically increasing.
Click this button to open the Lookup Table Editor. For more information, see Lookup Table Editor.
Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See How to Specify the Sample Time for more information.
The Algorithm pane of the Lookup Table (n-D) block dialog box appears as follows:

Select None - Flat, Linear (the default), or Cubic spline. See Interpolation Methods for more information.
Select None - Clip, Linear (the default), or Cubic spline. See Extrapolation Methods for more information.
Specify the indexing convention that the block uses to address the last element of a breakpoint set and its corresponding table value.
| Check Box Selection | Index That the Block Uses | Interval Fraction |
|---|---|---|
| Yes | The last element of a breakpoint set | 0 |
| No | The next-to-last element of a breakpoint set | 1 |
This parameter is visible only when:
Interpolation method is Linear.
Extrapolation method is None - Clip.
Select Evenly spaced points, Linear search, or Binary search (the default). Each search method has speed advantages in different circumstances:
For evenly spaced breakpoint sets (for example, 10, 20, 30, and so on), you achieve optimal speed by selecting Evenly spaced points to calculate table indices.
This algorithm uses only the first two breakpoints of a set to determine the offset and spacing of the remaining points.
For unevenly spaced breakpoint sets, follow these guidelines:
If input signals do not vary much between time steps, selecting Linear search with Begin index search using previous index result produces the best performance.
If input signals jump more than one or two table intervals per time step, selecting Binary search produces the best performance.
A suboptimal choice of index search method can lead to slow performance of models that rely heavily on lookup tables.
Select this check box when you want the block to start its search using the index found at the previous time step. For inputs that change slowly with respect to the interval size, enabling this option can improve performance. Otherwise, the linear search and binary search methods can take longer, especially for large breakpoint sets.
Instead of one input port per independent variable, use only one input port that expects a signal that is N elements wide for an N-dimensional table. This option is useful for removing line clutter on a block diagram with many lookup tables.
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
The Data Types pane of the Lookup Table (n-D) block dialog box appears as follows:

Note If you have more than two sets of breakpoint data, the dialog box expands to show additional data type options. Up to 30 breakpoint data type specifications can appear. |
Specify the table data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Same as output
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 parameter.
Tip Specify a table data type different from the output data type for these cases:
|
Specify the minimum value for table data. The default value, [], is equivalent to -Inf.
Specify the maximum value for table data. The default value, [], is equivalent to Inf.
Specify the data type for the first set of breakpoint data. You can set it to:
A rule that inherits a data type, for example, Inherit: Same as corresponding input
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 Breakpoints
1 parameter.
See Using the Data Type Assistant for more information.
Tip Specify a breakpoint data type different from the corresponding input data type for these cases:
|
Specify the minimum value that the first set of breakpoint data can have. The default value, [], is equivalent to -Inf.
Specify the maximum value that the first set of breakpoint data can have. The default value, [], is equivalent to Inf.
Specify the data type for the second set of breakpoint data. You can set it to:
A rule that inherits a data type, for example, Inherit: Same as corresponding input
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 Breakpoints
2 parameter.
See Using the Data Type Assistant for more information.
Tip Specify a breakpoint data type different from the corresponding input data type for these cases:
|
Specify the minimum value that the second set of breakpoint data can have. The default value, [], is equivalent to -Inf.
Specify the maximum value that the second set of breakpoint data can have. The default value, [], is equivalent to Inf.
Specify the fraction data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via internal rule
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 Fraction parameter.
See Using the Data Type Assistant for more information.
Specify the intermediate results data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Same as output
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 Intermediate
results parameter.
Specify the output data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via back propagation
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 Output parameter.
See Specifying Block Output Data Types for more information.
Specify the minimum value that the block outputs. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:
Parameter range checking (see Checking Parameter Values)
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the maximum value that the block outputs. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:
Parameter range checking (see Checking Parameter Values)
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Select to require all inputs to have the same data type.
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.
Select the rounding mode for fixed-point lookup table calculations that occur during simulation or execution of code generated from the model. For more information, see Rounding in the Simulink Fixed Point User's Guide.
This option does not affect rounding of values of block parameters. Simulink software rounds such values to the nearest representable integer value. To control the rounding of a block parameter, enter an expression using a MATLAB rounding function into the edit field on the block dialog box.
Select to have overflows saturate. Otherwise, they wrap.
When you select this check box, saturation applies to every internal operation on the block, not just the output or result. In general, the code generation process can detect when overflow is not possible, in which case, no saturation code is necessary.
For an example of entering breakpoint and table data, see Entering Data in a Block Parameter Dialog Box in the Simulink User's Guide.
For an example that illustrates linear interpolation and extrapolation methods of this block, see Example of a Logarithm Lookup Table in the Simulink User's Guide.
Direct Feedthrough | Yes |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes |
Dimensionalized | Yes, if you do not select Cubic spline for Interpolation method |
Zero-Crossing Detection | No |
![]() | Lookup Table (2-D) | Lookup Table Dynamic | ![]() |

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