Interpolation Using Prelookup - Use precalculated index and fraction values to accelerate approximation of
N-dimensional function - Simulink ([original](https://in.mathworks.com/help/simulink/slref/interpolationusingprelookup.html)) ([raw](?raw))
Use precalculated index and fraction values to accelerate approximation of N-dimensional function
Libraries:
Simulink / Lookup Tables
Description
The Interpolation Using Prelookup block is most efficient when used 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. Feed the resulting index and fraction values into an Interpolation Using Prelookup block to interpolate an _n_-dimensional table. These two blocks have distributed algorithms. When combined together, they perform the same operation as the integrated algorithm in the n-D Lookup Table block. 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.
Supported Block Operations
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 ask
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 |
How The Block Interpolates a Subset of Table Data
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 for the default column-major algorithm. Therefore, the value must be less than or equal to the Number of table dimensions.
For row-major algorithms, the interpolation starts from the first or lowest dimension of the table data.
For nonzero values, the subtable selection behavior is optimized for row-major layout when you select the > configuration parameter.
Suppose that you have 3-D table data in your Interpolation Using Prelookup block. This behavior applies for the column-major algorithm.
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 s3 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 s2 ands3 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, see Using the Prelookup and Interpolation Blocks.
For 2-D or n-D interpolation without subtable selection, the column-major and row-major algorithms may differ in the order of output calculations, causing slight different numerical results.
Examples
This example shows how to feed a breakpoint data set from a Constant block into the bp
input port of the Prelookup block.
The Prelookup block inherits these breakpoint attributes from the bp
input port:
- 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 these attributes:
- 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.
This example shows how to specify evenly spaced breakpoint data in the Prelookup block.
In the Breakpoints data section, the Specification parameter is set to Even spacing
. The parameters First point, Spacing, and Number of points are set to 25
, 12
, and 4
respectively. Specifying these parameters creates four evenly spaced breakpoints: [25, 37, 49, 61]
.
An alternative way to specify evenly spaced breakpoints is to set Specification to Explicit values
and set Value to [25:12:61]
.
Simulink® uses double-precision, floating-point data to perform the computations in this model. However, the model stores the breakpoints and table data as double.
This example shows how to output a bus containing the index (k
) and fraction (f
) from the Prelookup block. The bus object can then be used as an input to the Interpolation Using Prelookup block. The example also shows how to get the same results without using a bus object.
Open and simulate the model.
At the top of the model, open the dialog box for the Prelookup block. In the Main tab, note that Output selection is set to Index and fraction as bus
. In the Data Types tab, note that Output is set to Bus: myBus
. In the Simulink® Editor, select Modeling>Model Settings>Model Properties and open the Callbacks tab. In the model's PreLoadFcn
, the code defines the bus object myBus
, which specifies the index as the first bus element and the fraction as the second element.
Open the dialog box for the Interpolation Using Prelookup block. In the Main tab, note that Require index and fraction as bus check box is selected. That option configures the block to use the bus output from the Prelookup block.
Extended Examples
Ports
Input
Zero-based index, k
, specifying the interval containing the inputu
for the first dimension of the table.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
Fraction, f
, representing the normalized position of the input within the interval, k
, for the first dimension of the table.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
Zero-based index, k
, specifying the interval containing the input u
for then
-th dimension of the table.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
Fraction, f
, representing the normalized position of the input within the interval, k
, for then
-th dimension of the table.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
Inputs to the kf1 port contain indexk
and fraction f
specified as a bus object.
Dependencies
To enable this port, select the Require index and fraction as a bus check box.
The number of available kf
input ports depends on the value of the Number of dimensions andNumber of sub-table selection dimensions parameters.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
| bus
Inputs to the kfn port contain indexk
and fraction f
for the n-th dimension of the input, specified as a bus object.
Dependencies
To enable this port, select the Require index and fraction as a bus check box.
The number of available kf input ports depends on the value of the Number of dimensions and Number of sub-table selection dimensions parameters.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
| bus
For column-major algorithm, the block uses inputs to the s_m_, s_m_+1, ... s_n_ port to perform selection and interpolation within the subtables.m
maps to the_m_th dimension of the table. n equals the Number of dimensions.
For row-major algorithm, the block uses inputs to the s1, s2,... ,s_m_ port to perform selection and interpolation within the subtables. m
maps to the_m_th dimension of the table. m equals the Number of sub-table selection dimensions.
Dependencies
To enable this port, the Number of sub-table selection dimensions must be a positive integer less than or equal to the Number of dimensions.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
| enumerated
| bus
Table data values provided as input to port T. 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 (k
) and interval fraction (f
) values fed from Prelookup blocks.
Dependencies
To enable this port, set Source toInput port
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
Output
Approximation of N-dimensional function, computed by interpolating (or extrapolating) table data using values from the input index,k
, and fraction, f
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
Parameters
Main
Table data
Specify the number of dimensions that the table data must have. TheNumber of dimensions defines the number of independent variables for the table.
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. |
Programmatic Use
Block Parameter: NumberOfTableDimensions | ||||
---|---|---|---|---|
Type: character vector | ||||
Values: '1' | '2' | '3' | '4' | ... | '30' |
Default: '2' |
Select this check box to combine index and fraction inputs in a bus.
To enable the Prelookup block to supply input to theInterpolation Using Prelookup block, set:
- Output selection to
Index and fraction as bus
- Output to
Bus: <object name>
, where<object name>
must be a valid bus object name accessible to the model
Regardless of this check box setting, the selection port always operates in nonbus mode.
Programmatic Use
Block Parameter: RequireIndexFractionAsBus |
---|
Type: character vector |
Values: 'off' | 'on' |
Default: 'off' |
Specify whether to enter table data directly or use a lookup table object. If you set this parameter to:
Explicit values
, theSource and Value parameters are visible on the dialog box.Lookup table object
, theName parameter is visible on the dialog box.
Programmatic Use
Block Parameter: TableSpecification |
---|
Type: character vector |
Values: 'Explicit values' | 'Lookup table object' |
Default: 'Explicit values' |
To set this parameter from 'Explicit values'
to 'Lookup table object'
, use the sameset_param
call to set theLookupTableObject
parameter. For example:
set_param('myModel/myInterpBlock',... 'TableSpecification','Lookup table object',... 'LookupTableObject','myLUTObject')
Specify whether to enter table data in the dialog box or to inherit the data from an input port. If you set Source to:
Dialog
, enter table data in the text box underValueInput port
, verify that an upstream signal supplies table data to the table input port
Dependencies
To enable this parameter, set Specification toExplicit values
.
Programmatic Use
Block Parameter: TableSource |
---|
Type: character vector |
Values: 'Dialog' | 'Input port' |
Default: 'Dialog' |
Specify table data as an N
-D array, where N
is the value of the Number of dimensions parameter. You can edit the block diagram without specifying a correctly dimensioned matrix by entering an empty matrix ([]
) or an undefined workspace variable in the Value edit field. For information about how to construct multidimensional arrays in MATLAB®, see Multidimensional Arrays.
If you set Source to Input port
, verify that an upstream signal supplies table data to theT input port. The size of table data must match the Number of table dimensions. For this option, the block inherits table attributes from the T input port.
To edit lookup tables using the Lookup Table Editor, click Edit (see Lookup Table Editor).
Dependencies
To enable this parameter and explicitly specify table values on the dialog box, you must set Specification toExplicit values
andSource toDialog
.
Programmatic Use
Block Parameter: Table | ||
---|---|---|
Type: character vector | ||
Values: scalar | vector | matrix | N-D array |
Default: 'sqrt([1:11]' * [1:11])' |
Specify the name of a Simulink.LookupTable
object. A lookup table object references Simulink® breakpoint objects. If a Simulink.LookupTable
object does not exist, click the action button and selectCreate. The corresponding parameters of the new lookup table object are automatically populated with the block information.
Dependencies
To enable this parameter, set Specification to Lookup table object
.
Programmatic Use
Block Parameter: LookupTableObject |
---|
Type: character vector |
Value: Simulink.LookupTable object |
Default: '' |
Algorithm
Specify the method the block uses to interpolate table data. You can select Linear point-slope
, Flat
,Nearest
, or Linear Lagrange
. See Interpolation Methods for more information.
Programmatic Use
Block Parameter: InterpMethod | ||
---|---|---|
Type: character vector | ||
Values: 'Flat' | 'Linear point-slope' | 'Nearest' | 'Linear Lagrange' |
Default: 'Linear point-slope' |
Specify the method the block uses to extrapolate values for all inputs that fall outside the range of the breakpoint data set. You can selectClip
orLinear
. See Extrapolation Methods for more information.
If the extrapolation method is Linear
, the extrapolation value is calculated based on the selected linear interpolation method. For example, if the interpolation method is Linear Lagrange, the extrapolation method inherits the Linear Lagrange equation to compute the extrapolated value.
To use Prelookup and Interpolation Using Prelookup blocks to replicate n-D Lookup Table block behavior, the Extrapolation method for both Prelookup and Interpolation Using Prelookup blocks must be the same as if you use only the n-D Lookup Table block. For example, to get the same behavior as the n-D Lookup Table block with Extrapolation method set to Linear
, set Extrapolation method to Linear
for both Prelookup and Interpolation Using Prelookup blocks.
Dependencies
To enable the Extrapolation method parameter, set the Interpolation method toLinear
.
The Interpolation Using Prelookup block does not supportLinear
extrapolation when the input or output signals specify integer or fixed-point data types.
Programmatic Use
Block Parameter: ExtrapMethod |
---|
Type: character vector |
Values: 'Clip' | 'Linear' |
Default: 'Linear' |
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.
This check box is relevant if the input index is equal to or larger than the table's last index for that dimension. Due to rounding, selecting and clearing this check box may result in differing results for the last index between simulation and code generation.
Check Box | Block Behavior |
---|---|
on | Returns the value of the last element in a dimension of its table when: k indexes the last table element in the corresponding dimensionf is0 |
off | Returns the value of the last element in a dimension of its table when: k indexes the next-to-last table element in the corresponding dimensionf is1 |
Dependencies
This check box is visible only when:
- Interpolation method is
Linear point-slope
orLinear Lagrange
- 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.
Programmatic Use
Block Parameter: ValidIndexMayReachLast |
---|
Type: character vector |
Values: 'off' | 'on' |
Default: 'off' |
Since R2025a
Specify whether or not to include code that checks for out-of-range index values. Selecting this parameter means you guarantee that the block has no out-of-range indices, enabling the block to further optimize the code and simulation. The valid index range depends on the breakpoint data and the Extrapolation method setting.
When you select Assume index is within range:
- During simulation, the block assumes that there are no out-of-range indices and enforces this assumption by returning an error for out-of-range indices.
- For code generation, the block does not generate out-of-range index handling code because it assumes there is no out-of-range index. This means that if the block tries to generate code for a model that returns an error because of out-of-range indices, when the generated code is given the same index, the behavior is undefined, which can lead to severe consequence.
Warning
If the model tries to generate code and instead generates an error because the block detects out-of-range indices, the behavior is undefined if the same out-of-range index is passed to deployed code. This undefined behavior might cause severe issues. For safety critical applications, do not select Assume index is within range.
If you want to select the Assume index is within range parameter for efficiency, ensure that your model indices are in range. For example:
Parameter | Result | When to Use |
---|---|---|
on | Simulation and generated code does not include conditional statements to check for out-of-range breakpoint indices.When the index is out-of-range, it may cause undefined behavior for simulation and generated code. | For simulation and code efficiency |
off | Simulation and generated code includes conditional statements to check for out-of-range indices. | For safety-critical applications |
If you are confident your indices is within range, you can select the Assume index is within range parameter for efficiency. By default, this parameter is cleared. For safety-critical applications, do not select this parameter. If you want to select the Assume index is within range parameter, first check that your model indices are in range. For example:
- Clear the Assume index is within range parameter.
- Set the Diagnostic for out-of-range index parameter to
Error
. - Simulate the model in normal mode.
- If there are out-of-range errors, the block returns runtime errors. Fix them to be in range and run the simulation again.
- When the simulation no longer generates out-of-range index errors, select theAssume index is within range parameter.
Note
When you select the Assume index is within range parameter and the index is out of range, the block returns a runtime error at simulation. The behavior is undefined for generated code.
Depending on your application, you can run the following Model Advisor checks to verify the usage of this parameter:
- > >
- > > > >
For more information about the Model Advisor, see Run Model Advisor Checks.
Additionally, to determine if it is safe to select this parameter, if you have aSimulink Design Verifier™ license, consider using the Detect Block Input Range Violations (Simulink Design Verifier) check.
Programmatic Use
Block Parameter: RemoveProtectionIndex |
---|
Type: character vector |
Values: 'off' | 'on' |
Default: 'off' |
Specify whether to produce a warning or error when the input is out of range. Options include:
None
— Produce no response.Warning
— Display a warning and continue the simulation.Error
— Terminate the simulation and display an error.
Dependencies
To enable this parameter, clear the Assume input is within range or Assume index is within range parameter.
Programmatic Use
Block Parameter: DiagnosticForOutOfRangeInput | |
---|---|
Type: character vector | |
Values: 'None' | 'Warning' | 'Error' |
Default: 'None' |
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 theNumber of table dimensions. - To disable subtable selection, enter
0
to interpolate the entire table.
For nonzero values, the subtable selection behavior is optimized for row-major layout when you select the > configuration parameter.
For more information, see How The Block Interpolates a Subset of Table Data.
Programmatic Use
Block Parameter: NumSelectionDims | |||||
---|---|---|---|---|---|
Type: character vector | |||||
Values: '0' | '1' | '2' | '3' | '4' | ... | Number of table dimensions |
Default: '0' |
Specify the time interval between samples. To inherit the sample time, set this parameter to -1
. For more information, see Specify Sample Time.
Dependencies
This parameter is visible only if you set it to a value other than-1
. To learn more, see Blocks for Which Sample Time Is Not Recommended.
Programmatic Use
To set the block parameter value programmatically, use the set_param function.
Parameter: | SampleTime |
---|---|
Values: | "-1" (default) | scalar or vector in quotes |
Data Types
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:
- Lower memory requirement for storing table data that uses a smaller type than the output signal
- Sharing of prescaled table data between twoInterpolation Using Prelookup blocks with different output data types
- Sharing of custom storage table data in Simulink Coder™ generated code for blocks with different output data types
Programmatic Use
Block Parameter: TableDataTypeStr | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type: character vector | ||||||||||||||
Values: 'Inherit: Inherit from table data' | 'Inherit: Same as output' | 'double' | 'single' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'int64' | 'uint64' | 'fixdt(1,16)' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)' | '' |
Default: 'Inherit: Same as output' |
Specify the minimum value for table data as a finite, real, double, scalar. The default value is []
(unspecified).
Programmatic Use
Block Parameter: TableMin |
---|
Type: character vector |
Values: scalar |
Default: '[]' |
Specify the maximum value for table data as a finite, real, double, scalar. The default value is []
(unspecified).
Programmatic Use
Block Parameter: TableMax |
---|
Type: character vector |
Values: scalar |
Default: '[]' |
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)
The Data Type Assistant helps you set data attributes. To use the Data Type Assistant, click . For more information, see Specify Data Types Using Data Type Assistant.
Tip
Use this parameter to specify higher precision for internal computations than for table data or output data.
Programmatic Use
Block Parameter: IntermediateResultsDataTypeStr | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type: character vector | ||||||||||||||
Values: 'Inherit: Inherit via internal rule' | 'Inherit: Same as output' | 'double' | 'single' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'int64' | 'uint64' | 'fixdt(1,16)' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)' | '' |
Default: 'Inherit: Inherit via internal rule' |
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 Control Data Types of Signals for more information.
Programmatic Use
Block Parameter: OutDataTypeStr | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type: character vector | ||||||||||||||
Values: 'Inherit: Inherit via back propagation' | 'Inherit: Inherit from table data' | 'double' | 'single' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'int64' | 'uint64' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)' | 'fixdt(1,16,2^0,0)' | '' |
Default: 'Inherit: Inherit from table data' |
Specify the minimum value that the block should output as a finite, real-valued scalar. The default value is []
(unspecified). Simulink software uses this value to perform:
- Parameter range checking (see Specify Minimum and Maximum Values for Block Parameters).
- Simulation range checking (see Specify Signal Ranges).
- Automatic scaling of fixed-point data types.
- Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Programmatic Use
Block Parameter: OutMin |
---|
Type: character vector |
Values: scalar |
Default: '[]' |
Specify the maximum value that the block should output as a finite, real-valued scalar. The default value is []
(unspecified). Simulink software uses this value to perform:
- Parameter range checking (see Specify Minimum and Maximum Values for Block Parameters).
- Simulation range checking (see Specify Signal Ranges).
- Automatic scaling of fixed-point data types.
- Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Programmatic Use
Block Parameter: OutMax |
---|
Type: character vector |
Values: scalar |
Default: '[]' |
Specify the internal rule for intermediate calculations. SelectSpeed
for faster calculations. If you do, a loss of accuracy might occur, usually up to 2 bits.
Programmatic Use
Block Parameter: InternalRulePriority |
---|
Type: character vector |
Values: 'Speed' | 'Precision' |
Default: 'Speed' |
Select this parameter to prevent the fixed-point tools from overriding the data types you specify on this block. For more information, see Lock the Output Data Type Setting (Fixed-Point Designer).
Programmatic Use
Block Parameter: LockScale |
---|
Type: character vector |
Values: 'off' | 'on' |
Default: 'off' |
Specify the rounding mode for fixed-point operations. For more information, see Rounding Modes (Fixed-Point Designer).
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.
Programmatic Use
Block Parameter: RndMeth | |||||
---|---|---|---|---|---|
Type: character vector | |||||
Values: 'Ceiling' | 'Convergent' | 'Floor' | 'Nearest' | 'Round' | 'Simplest' | 'Zero' |
Default: 'Floor' |
Specify whether overflows saturate or wrap.
on
— Overflows saturate to either the minimum or maximum value that the data type can represent.off
— Overflows wrap to the appropriate value that the data type can represent.
For example, the maximum value that the signed 8-bit integer int8
can represent is 127. Any block operation result greater than this maximum value causes overflow of the 8-bit integer.
- With this parameter selected, the block output saturates at 127. Similarly, the block output saturates at a minimum output value of -128.
- With this parameter cleared, the software interprets the overflow-causing value as
int8
, which can produce an unintended result. For example, a block result of 130 (binary 1000 0010) expressed asint8
is -126.
Tips
- Consider selecting this parameter when your model has a possible overflow and you want explicit saturation protection in the generated code.
- Consider clearing this parameter when you want to optimize efficiency of your generated code. Clearing this parameter also helps you to avoid overspecifying how a block handles out-of-range signals. For more information, see Troubleshoot Signal Range Errors.
- When you select this parameter, 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.
Programmatic Use
To set the block parameter value programmatically, use the set_param function.
Parameter: | SaturateOnIntegerOverflow |
---|---|
Values: | 'off' (default) | 'on' |
Block Characteristics
Data Types | double | fixed point | integer | single |
---|---|---|---|
Direct Feedthrough | yes | ||
Multidimensional Signals | yes | ||
Variable-Size Signals | no | ||
Zero-Crossing Detection | no |
Extended Capabilities
Simulink PLC Coder™ has limited support for lookup table blocks. The coder does not support:
- Number of dimensions greater than 2
- Cubic spline interpolation method
- Begin index search using a previous index mode
- Cubic spline extrapolation method
Version History
Introduced in R2006b
The Remove protection against out-of-range index in generated code parameter has been replaced by Assume index is within range. The programmatic name, RemoveProtectionInput
, remains the same.
If the model simulation generates errors because the out-of-range index is fed to a block with Assume index is within range selected, the code generated by the model has undefined behavior when the same out-of-range index occurs during execution of the generated code. This situation might cause severe issues. This undefined behavior might cause severe issues. For safety critical applications, do not select Remove protection against out-of-range index in generated code.
In releases prior to R2025a, the Remove protection against out-of-range index in generated code only removed the code checks for out-of-range values for generated code. The block failed to detect these issues. As a workaround. if you have a model from a release prior to R2025a and cannot migrate to a later release, set the Diagnostic for out-of-range input parameter to Error
. The next time you run the model, an error is generated when the index is out-of-range.
See Also
Blocks
Tools
Topics
- About Lookup Table Blocks
- Anatomy of a Lookup Table
- Enter Breakpoints and Table Data
- Guidelines for Choosing a Lookup Table
- Column-Major Layout to Row-Major Layout Conversion of Models with Lookup Table Blocks (Simulink Coder)
- Interpolation with Subtable Selection Algorithm for Row-Major Array Layout (Simulink Coder)