| Simulink® | ![]() |
Lookup Tables

The Prelookup block is intended for use with the Interpolation Using Prelookup block. The Prelookup block calculates the index and interval fraction that specifies how its input value 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 equivalent operation that a single instance of the Lookup Table (n-D) block performs. However, the Prelookup and Interpolation Using Prelookup blocks offer greater flexibility that can result in more efficient simulation performance.
To use this block, you must define a set of breakpoint values. In normal use, this breakpoint data set corresponds to one dimension of the Table data parameter in an Interpolation Using Prelookup block. The block generates a pair of outputs for each input value by calculating the
Index of the breakpoint set element that is less than or equal to the input value
Resulting fractional value that is a number 0 ≤ f < 1, representing the input value's normalized position 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, denoted respectively as k and f on the block. Note that the index value is zero-based.
Note The interval fraction can be negative or greater than 1 for out-of-range input. See the documentation for the block's Process out of range input parameter for more information. |
The Prelookup block accepts real signals of any numeric data type supported by Simulink software, except Boolean. The Prelookup block supports 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.
The Main pane of the Prelookup block dialog appears as follows:

The set of numbers to search. Specify a strictly monotonically increasing vector that contains two or more elements.
Note At runtime, the Prelookup block converts the data type of its Breakpoint data parameter to that of its input. |
Click the Edit button to open the Lookup Table Editor (see Lookup Table Editor in the Simulink documentation).
Binary search, Evenly spaced points, or Linear search. Use Linear search in combination with Begin index search using previous index result for more efficient performance than Binary search when the input values do not change much from one time step to the next. For large breakpoint data sets, a linear search can be very slow if the input value changes by more than a few intervals from one time step to the next. Use Evenly spaced points if the elements of the Breakpoint data parameter are spaced apart evenly.
Select this option if you want the block to start its search using the index that was found at the previous time step. For inputs that change slowly with respect to the interval size, you can realize a large performance gain.
If this block is not being used to feed an Interpolation Using Prelookup block, the interval fraction output can be dropped. In this case, the block outputs only the resulting index value.
Specifies how to handle out-of-range input. Options include:
Clip to range
If the input is less than the first breakpoint, return the index of the first breakpoint (i.e., 0) and 0 for the interval fraction. If the input is greater than the last breakpoint, return the index of the next-to-last breakpoint and 1 for the interval fraction. For example, suppose the range is [1 2 3] and you select this option. Then, if the input is 0.5, the index is 0 and the interval fraction is 0; if the input is 3.5, the index is 1 and the interval fraction is 1.
Linear extrapolation
If the input is less than the first breakpoint, return the index of the first breakpoint (i.e., 0) and an interval fraction representing the linear distance from the input to the first breakpoint. If the input is greater than the last breakpoint, return the index of the next-to-last breakpoint and an interval fraction that represents the linear distance from the next-to-last breakpoint to the input. For example, suppose the range is [1 2 3] and you select this option. Then, if the input is 0.5, the index is 0 and the interval fraction is -0.5; if the input is 3.5, the index is 1 and the interval fraction is 1.5.
The Prelookup block supports Linear extrapolation only if all of the following conditions apply:
The block input and its interval fraction specify the same floating-point data type.
The data type of its index specifies a built-in integer.
Specifies how to index inputs that are greater than or equal to the last breakpoint. If enabled when the block input equals the last breakpoint, the block returns the index of the last element in the breakpoint data set and 0 for the interval fraction. If disabled in this situation, the block returns the index of the next-to-last breakpoint and 1 for the interval fraction. Note that the index value is zero-based.
This parameter is visible only if Output only the index is unchecked and Process out of range input is Clip to range. However, if Output only the index is checked and Process out of range input is Clip to range, the block behaves as if this parameter is enabled even though it is invisible.
Note If you enable the Use last breakpoint for input at or above upper limit parameter for a Prelookup block, you must also enable the Valid index input may reach last index parameter for the Interpolation Using Prelookup block to which it connects. This allows the blocks to use the same indexing convention when accessing the last elements of their Breakpoint data and Table data parameters. |
Specifies whether to produce a warning or error message if the input is out of range. The options are
None — the default, 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
Specifies the time interval between samples. To inherit the sample time, set this parameter to -1. See Specifying Sample Time in the Simulink documentation for more information.
The Signal Attributes pane of the Prelookup block dialog appears as follows:

Specify how the data type of the index is designated. You can choose a built-in integer data type from the list, or you can specify an integer data type using a fixed-point representation. The data type that you specify must be capable of indexing all elements in the Breakpoint data parameter.
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Index
data type parameter.
See Using the Data Type Assistant for more information.
Specify how the data type of the interval fraction is designated. You can choose a built-in data type from the list, specify that the data type is inherited through an internal rule, or specify a fixed-point data type using either the [Slope Bias] or the binary-point-only scaling representation. If using the [Slope Bias] representation, the scaling must be trivial — i.e., the slope is 1 and the bias is 0. If using 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 parameter.
See Using the Data Type Assistant for more information.
Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Fraction data type parameter.
Select the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink Fixed Point User's Guide.
Block parameters such as Breakpoint data are always rounded 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.
Direct Feedthrough | Yes |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes |
Dimensionalized | Yes |
Zero Crossing | No |
![]() | Polynomial | Probe | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |