| Contents | Index |
Lookup Tables
The Interpolation Using Prelookup block works best with the 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 Interpolation Using Prelookup block, you specify a set of table data values directly on the dialog box or feed values into the T input port. Typically, these table values correspond to the breakpoint data sets specified in Prelookup blocks. The Interpolation Using Prelookup block generates output by looking up or estimating table values based on index and interval fraction values fed from Prelookup blocks. Labels for the index and interval fraction appear as k and f on the Interpolation Using Prelookup block icon.
| When inputs for index and interval fraction... | The Interpolation Using Prelookup block... |
|---|---|
| Map to values in breakpoint data sets | Outputs the table value at the intersection of the row, column, and higher dimension breakpoints |
| Do not map to values in breakpoint data sets, but are within range | Interpolates appropriate table values, using the Interpolation method you select |
| Do not map to values in breakpoint data sets, and are out of range | Extrapolates the output value, using the Extrapolation method you select |
You can use the Number of sub-table selection dimensions parameter to specify that interpolation occur only on a subset of the table data. To activate this interpolation mode, set this parameter to a positive integer. This value defines the number of dimensions to select, starting from the highest dimension of table data. Therefore, the value must be less than or equal to the Number of table dimensions.
Suppose that you have 3-D table data in your Interpolation Using Prelookup block. The following behavior applies.
| Number of Selection Dimensions | Action by the Block | Block Appearance |
|---|---|---|
| 0 | Interpolates the entire table and does not activate subtable selection | Does not change |
| 1 | Interpolates the first two dimensions and selects the third dimension | Displays an input port with the label sel1 that you use to select and interpolate 2-D tables |
| 2 | Interpolates the first dimension and selects the second and third dimensions | Displays two input ports with the labels sel1 and sel2 that you use to select and interpolate 1-D tables |
Subtable selection uses zero-based indexing. For an example of interpolating a subset of table data, type sldemo_bpcheck at the MATLAB command prompt.
The Interpolation Using Prelookup block accepts real signals of any numeric data type supported by Simulink software, except Boolean. The Interpolation Using Prelookup block supports fixed-point data types for signals, table data, and intermediate results.
For more information, see Data Types Supported by Simulink in the Simulink documentation.
The Main pane of the Interpolation Using Prelookup block dialog box appears as follows:

Specify the number of dimensions that the table data must have. This value defines the number of independent variables for the table. Enter an integer between 1 and 30 into this field.
Specify whether to enter table data directly on the dialog box or to inherit the data from an input port.
If you set Source to Dialog, enter table data in the edit field under Value. The size of the table data must match the Number of table dimensions. For this option, you specify table attributes on the Data Types pane.
If you set Source to Input port, verify that an upstream signal supplies table data to the T input port. The size of the table data must match the Number of table dimensions. For this option, your block inherits table attributes from the T input port.
During block diagram editing, you can enter an empty matrix (specified as []) or an undefined workspace variable in the edit field under Value. Use this behavior to 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, see Multidimensional Arrays in the MATLAB documentation.
Click the Edit button to open the Lookup Table Editor (see Lookup Table Editor in the Simulink documentation).
Select Flat or Linear. See Interpolation Methods in the Simulink documentation for more information.
Select Clip or Linear. See Extrapolation Methods in the Simulink documentation for more information. The Extrapolation method parameter is visible only when you select Linear as the Interpolation method parameter.
The Interpolation Using Prelookup block does not support Linear extrapolation when the input or output signals specify integer or fixed-point data types.
Specify how block inputs for index (k) and interval fraction (f) access the last elements of n-dimensional table data. Index values are zero-based.
| Check Box | Block Behavior |
|---|---|
Selected | Returns the value of the last element in a dimension of its table when:
|
Cleared | Returns the value of the last element in a dimension of its table when:
|
This check box is visible only when:
Interpolation method is Linear.
Extrapolation method is Clip.
Tip When you select Valid index input may reach last index for an Interpolation Using Prelookup block, you must also select Use last breakpoint for input at or above upper limit for all Prelookup blocks that feed it. 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 k or f 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 index inputs.
| Check Box | Result | When to Use |
|---|---|---|
Selected | Generated code does not include conditional statements to check for out-of-range index inputs. | For code efficiency |
Cleared | Generated code includes conditional statements to check for out-of-range index 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.
This check box has no effect on generated code when one of the following is true:
The Prelookup block feeds index values to the Interpolation Using Prelookup block.
Because index values from the Prelookup block are always valid, no check code is necessary.
The data type of the input k restricts the data to valid index values.
For example, unsigned integer data types guarantee nonnegative index values. Therefore, unsigned input values of k do not require check code for negative values.
Specify the number of dimensions of the subtable that the block uses to compute the output. Follow these rules:
To enable subtable selection, enter a positive integer.
This integer must be less than or equal to the Number of table dimensions.
To disable subtable selection, enter 0 to interpolate the entire table.
For more information, see How The Block Interpolates a Subset of Table Data.
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 Data Types pane of the Interpolation Using Prelookup block dialog box appears as follows:

Note The parameters for table attributes (data type, minimum, and maximum) are not available when you set Source to Input port. In this case, the block inherits all table attributes from the T input port. |
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 type.
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 [] (unspecified).
Specify the maximum value for table data. The default value is [] (unspecified).
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
data type.
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 data type.
See Specifying Block Output Data Types for more information.
Specify the minimum value that the block should output. The default value is [] (unspecified). Simulink software uses this value to perform:
Parameter range checking (see Checking Parameter Values)
Simulation range checking (see Signal Ranges)
Automatic scaling of fixed-point data types
Specify the maximum value that the block should output. The default value is [] (unspecified). Simulink software uses this value to perform:
Parameter range checking (see Checking Parameter Values)
Simulation range checking (see Signal Ranges)
Automatic scaling of fixed-point data types
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.
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 in the mask field.
| Action | Reasons for Taking This Action | What Happens for Overflows | Example |
|---|---|---|---|
Select this check box. | Your model has possible overflow and you want explicit saturation protection in the generated code. | Overflows saturate to either the minimum or maximum value that the data type can represent. | An overflow associated with a signed 8-bit integer can saturate to -128 or 127. |
Do not select this check box. | You want to optimize efficiency of your generated code. You want to avoid overspecifying how a block handles out-of-range signals. For more information, see Checking for Signal Range Errors. | Overflows wrap to the appropriate value that is representable by the data type. | The number 130 does not fit in a signed 8-bit integer and wraps to -126. |
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 this case, the code generator does not produce saturation code.
In the following model, a Constant block feeds the table data values to the T input port of the Interpolation Using Prelookup block.

The Interpolation Using Prelookup block inherits the following table attributes from the T input port:
| Table Attribute | Value |
|---|---|
| Minimum | –Inf |
| Maximum | Inf |
| Data type | single |
Similarly, a Constant block feeds the breakpoint data set to the bp input port of the Prelookup block, which inherits the following breakpoint attributes:
| Breakpoint 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 |