| Contents | Index |
Lookup Tables
The Prelookup block works best with the Interpolation Using Prelookup block. The Prelookup block calculates the index and interval fraction that specify how its input value u relates to the breakpoint data set. You feed the resulting index and fraction values into an Interpolation Using Prelookup block to interpolate an n-dimensional table. This combination of blocks performs the same operation that a single instance of the n-D Lookup Table block performs. However, the Prelookup and Interpolation Using Prelookup blocks offer greater flexibility that can provide more efficient simulation and code generation. For more information, see Efficiency of Performance in the Simulink User's Guide.
To use the Prelookup block, you specify a set of breakpoint values directly on the dialog box or feed values into the bp input port. Typically, this breakpoint data set corresponds to one dimension of the table data in an Interpolation Using Prelookup block. The Prelookup block generates a pair of outputs for each input value u by calculating:
The index of the breakpoint set element that is less than or equal to u and forms an interval containing u
The interval fraction in the range 0 ≤ f < 1, which represents the normalized position of u on the breakpoint interval between the index and the next index value for in-range input
For example, if the breakpoint data set is [ 0 5 10 20 50 100 ] and the input value u is 55, the index is 4 and the fractional value is 0.1. Labels for the index and interval fraction appear as k and f on the Prelookup block icon. The index value is zero-based.
The interval fraction can be negative or greater than 1 for out-of-range input. See the documentation for the Extrapolation method block parameter for more information.
The Prelookup block accepts real signals of any numeric data type that Simulink supports, except Boolean. The Prelookup block supports fixed-point data types for signals and breakpoint data.
For more information, see Data Types Supported by Simulink in the Simulink documentation.
The Main pane of the Prelookup block dialog box appears as follows:

Specify whether to enter breakpoint data directly on the dialog box or to inherit the data from an input port.
If you set Source to Dialog, enter breakpoint data in the edit field under Value. Each breakpoint data set must be a strictly monotonically increasing vector that contains two or more elements. For this option, you specify breakpoint attributes on the Data Types pane.
If you set Source to Input port, verify that an upstream signal supplies breakpoint data to the bp input port. Each breakpoint data set must be a strictly monotonically increasing vector that contains two or more elements. For this option, your block inherits breakpoint attributes from the bp input port.
Click the Edit button to open the Lookup Table Editor (see Lookup Table Editor in the Simulink documentation).
Tip To learn how to define evenly spaced breakpoints, see Formulation of Evenly Spaced Breakpoints in the Simulink documentation. |
Select Evenly spaced points, Linear search, or Binary search. Each search method has speed advantages in different situations:
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 values for u do not vary much between time steps, selecting Linear search with Begin index search using previous index result produces the best performance.
If input values for u 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 input values of u 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.
Select this check box when you want the block to output only the resulting index value, without the interval fraction.
Typical applications include:
Feeding a Direct Lookup Table (n-D) block, with no interpolation on the interval
Feeding selection ports of a subtable selection for an Interpolation Using Prelookup block
Performing nonlinear quantizations
Specify how to handle out-of-range values for the block input u. Options include:
Clip
| Block Input | Block Outputs |
|---|---|
Less than the first breakpoint |
|
Greater than the last breakpoint |
|
Suppose the range is [1 2 3] and you select this option. If u is 0.5, the index is 0 and the interval fraction is 0. If u is 3.5, the index is 1 and the interval fraction is 1.
Linear
| Block Input | Block Outputs |
|---|---|
Less than the first breakpoint |
|
Greater than the last breakpoint |
|
Suppose the range is [1 2 3] and you select this option. If u is 0.5, the index is 0 and the interval fraction is -0.5. If u is 3.5, the index is 1 and the interval fraction is 1.5.
Specify how to index input values of u that are greater than or equal to the last breakpoint. The index value is zero-based. When input equals the last breakpoint, block outputs differ as follows:
| Check Box | Block Outputs |
|---|---|
Selected |
|
Cleared |
|
This check box is visible only when:
Output only the index is cleared.
Extrapolation method is Clip.
However, when Output only the index is selected and Extrapolation method is Clip, the block behaves as if this check box is selected even though it is invisible.
Tip When you select Use last breakpoint for input at or above upper limit for a Prelookup block, you must also select Valid index input may reach last index for the Interpolation Using Prelookup block to which it connects. This action allows the blocks to use the same indexing convention when accessing the last elements of their breakpoint and table data sets. |
Specify whether to produce a warning or error when the input u is out of range. Options include:
None — no warning or error
Warning — display a warning in the MATLAB Command Window and continue the simulation
Error — halt the simulation and display an error in the Simulation Diagnostics Viewer
Specify whether or not to include code that checks for out-of-range breakpoint inputs.
| Check Box | Result | When to Use |
|---|---|---|
Selected | Generated code does not include conditional statements to check for out-of-range breakpoint inputs. | For code efficiency |
Cleared | Generated code includes conditional statements to check for out-of-range breakpoint inputs. | For safety-critical applications |
Depending on your application, you can run the following Model Advisor checks to verify the usage of this check box:
By Product > Embedded Coder > Identify lookup table blocks that generate expensive out-of-range checking code
By Product > Simulink Verification and Validation > Modeling Standards > DO-178B Checks > Check usage of lookup table blocks
For more information about the Model Advisor, see Consulting the Model Advisor in the Simulink documentation.
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 User's Guide for more information.
The Data Types pane of the Prelookup block dialog box appears as follows:

Note The parameters for breakpoint attributes (data type, minimum, and maximum) are not available when you set Source to Input port. In this case, the block inherits all breakpoint attributes from the bp input port. |
Specify the breakpoint data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Same as 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 breakpoint data
type.
See Using the Data Type Assistant for more information.
Tip Specify a breakpoint data type different from the data type of input u for these cases:
|
Specify the minimum value that the breakpoint data can have. The default value is [] (unspecified).
Specify the maximum value that the breakpoint data can have. The default value is [] (unspecified).
Specify a data type that can index all elements in the breakpoint data set. You can:
Select a built-in integer data type from the list.
Specify an integer data type using a fixed-point representation.
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the index data type.
See Using the Data Type Assistant for more information.
Specify the data type of the interval fraction. You can:
Select a built-in data type from the list.
Specify data type inheritance through an internal rule.
Specify a fixed-point data type using the [Slope Bias] or binary-point-only scaling representation.
If you use the [Slope Bias] representation, the scaling must be trivial — that is, the slope is 1 and the bias is 0.
If you use the binary-point-only representation, the fixed power-of-two exponent must be less than or equal to zero.
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the fraction data type.
See Using the Data Type Assistant for more information.
Select to lock the output data type setting 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.
Specify the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink Fixed Point User's Guide.
Block parameters always round to the nearest representable value. To control the rounding of a block parameter, enter an expression using a MATLAB rounding function into the mask field.
In the following model, a Constant block feeds the breakpoint data set to the bp input port of the Prelookup block.

The Prelookup block inherits the following breakpoint attributes from the bp input port:
| Breakpoint Attribute | Value |
|---|---|
| Minimum | –Inf |
| Maximum | Inf |
| Data type | single |
Similarly, a Constant block feeds the table data values to the T input port of the Interpolation Using Prelookup block, which inherits the following table attributes:
| Table Attribute | Value |
|---|---|
| Minimum | –Inf |
| Maximum | Inf |
| Data type | single |
Simulink uses double-precision, floating-point data to perform the computations in this model. However, the model stores the breakpoint and table data as single-precision, floating-point data. Using a lower-precision data type to store breakpoint and table data reduces the memory requirement.
For other examples, see Examples for Prelookup and Interpolation Blocks in the Simulink documentation.
Direct Feedthrough | Yes |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes |
Dimensionalized | 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 |