Interpolation Using Prelookup
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 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 |
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 Math and Data Types > Use algorithms optimized for row-major array layout 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 and
s3 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
Prelookup with External Breakpoint Specification
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.
Prelookup with Evenly Spaced Breakpoints
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.
Configure the Prelookup Block to Output Index and Fraction as a Bus
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
Using the Prelookup and Interpolation Blocks
Use the Prelookup and Interpolation Using Prelookup blocks.
Ports
Input
k1 — Index, k
, for the first dimension of the
table
scalar | vector | matrix
Zero-based index, k
, specifying the interval containing the input
u
for the first dimension of the table.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
f1 — Fraction, f
, for the first dimension of the table
scalar | vector | matrix
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
kn — Index, k
, for the n
-th dimension of the table
scalar | vector | matrix
Zero-based index, k
, specifying the interval
containing the input u
for the
n
-th dimension of the table.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
fn — Fraction, f
, for the n
-th dimension of the table
scalar | vector | matrix
Fraction, f
, representing the normalized position
of the input within the interval, k
, for the
n
-th dimension of the table.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
kf1 — Input containing index k
and fraction f
bus object
Inputs to the kf1 port contain index
k
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 and
Number of sub-table selection dimensions
parameters.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
| bus
kfn — Input containing index k
and fraction f
bus object
Inputs to the kfn port contain index
k
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
sm — Select and interpolate a subset of the table data
scalar | vector | matrix
For column-major algorithm, the block uses inputs to the sm,
sm+1, ... sn port to perform
selection and interpolation within the subtables.
m
maps to the
mth dimension of the
table. n equals the Number of
dimensions.
For row-major algorithm, the block uses inputs to the s1, s2,...
,sm port to perform selection and interpolation
within the subtables. m
maps to the
mth 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
T — Table data
scalar | vector | matrix | n-d array
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 to
Input port
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
Output
Port_1 — Approximation of N-dimensional function
scalar | vector | matrix
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 dataNumber of dimensions — Number of table data dimensions
2
(default) | integer between 1 and 30
Specify the number of dimensions that the table data must have. The Number 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' |
Require index and fraction as bus — Index and fraction inputs can be combined in a bus
off
(default) | on
Select this check box to combine index and fraction inputs in a bus.
To enable the Prelookup block to supply input to the Interpolation 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' |
Specification — Choose how to enter table data
Explicit values
(default) | Lookup table object
Specify whether to enter table data directly or use a lookup table object. If you set this parameter to:
Explicit values
, the Source and Value parameters are visible on the dialog box.Lookup table object
, the Name 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 same
set_param
call to set the
LookupTableObject
parameter. For
example:
set_param('myModel/myInterpBlock',... 'TableSpecification','Lookup table object',... 'LookupTableObject','myLUTObject')
Source — Source of table data
Dialog
(default) | Input port
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 under ValueInput port
, verify that an upstream signal supplies table data to the table input port
Dependencies
To enable this parameter, set Specification to
Explicit values
.
Programmatic Use
Block Parameter:
TableSource |
Type: character vector |
Values:
'Dialog' | 'Input port' |
Default:
'Dialog' |
Value — Specify table data values
sqrt([1:11]' * [1:11])
(default) | multidimensional array of table data
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 the
T 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 Edit Lookup Tables).
Dependencies
To enable this parameter and explicitly specify table values on
the dialog box, you must set Specification to
Explicit values
and
Source to
Dialog
.
Programmatic Use
Block Parameter:
Table |
Type: character vector |
Values: scalar | vector | matrix | N-D array |
Default:
'sqrt([1:11]' * [1:11])' |
Name — Name of a Simulink.LookupTable
object
Simulink.LookupTable object
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 select
Create. 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:
'' |
Interpolation method — Select Linear point-slope
, Flat
, Nearest
, or Linear Lagrange
Linear point-slope
(default) | Nearest
| Flat
| Linear Lagrange
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' |
Extrapolation method — Method of handling input that falls outside the range of the breakpoint data set
Linear
(default) | Clip
Specify the method the block uses to extrapolate values for all inputs
that fall outside the range of the breakpoint data set. You can select
Clip
or
Linear
. 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 to
Linear
.
The Interpolation Using Prelookup block does not support
Linear
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' |
Valid index input may reach last index — Allow inputs to access the last elements of table data
off
(default) | on
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 |
---|---|
|
Returns the value of the last element in a dimension of its table when:
|
|
Returns the value of the last element in a dimension of its table when:
|
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' |
Diagnostic for out-of-range input — Block action when input is out of range
None
(default) | Warning
| Error
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.
Programmatic Use
Block Parameter: DiagnosticForOutOfRangeInput |
Type: character vector |
Values: 'None' | 'Warning' | 'Error' |
Default: 'None' |
Number of sub-table selection dimensions — Number of dimensions of the output computation subtable
0
(default) | positive integer, less than or equal to the number of table
dimensions
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 nonzero values, the subtable selection behavior is optimized for row-major layout when you select the Math and Data Types > Use algorithms optimized for row-major array layout 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' |
Remove protection against out-of-range index in generated code — Remove code that checks for out-of-range index inputs
off
(default) | on
Check Box | Result | When to Use |
---|---|---|
| Generated code does not include conditional statements to check for out-of-range index inputs. When the
input |
For code efficiency |
|
Generated code includes conditional statements to check for out-of-range index inputs. |
For safety-critical applications |
If your input is not out of range, you can select the Remove protection against out-of-range index in generated code check box for code efficiency. By default, this check box is cleared. For safety-critical applications, do not select this check box. If you want to select the Remove protection against out-of-range index in generated code check box, first check that your model inputs are in range. For example:
Clear the Remove protection against out-of-range index in generated code check box.
Set the Diagnostic for out-of-range input parameter to
Error
.Simulate the model in normal mode.
If there are out-of-range errors, fix them to be in range and run the simulation again.
When the simulation no longer generates out-of-range input errors, select the Remove protection against out-of-range index in generated code check box.
Note
When you select the Remove protection against out-of-range index in generated code check box and the input
k
orf
is out of range, 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 check box:
By Product > Embedded Coder > Identify lookup table blocks that generate expensive out-of-range checking code
By Product > Simulink Check > Modeling Standards > DO-178C/DO-331 Checks > Check usage of lookup table blocks
For more information about the Model Advisor, see Run Model Advisor Checks.
Additionally, to determine if it is safe to select this check box, if you have a Simulink Design Verifier™ license, consider using the Detect Block Input Range Violations (Simulink Design Verifier) check.
This check box has no effect on the 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.
Programmatic Use
Block Parameter:
RemoveProtectionIndex |
Type: character vector |
Values:
'off' | 'on' |
Default:
'off' |
Sample time (-1 for inherited) — Interval between samples
-1
(default) | scalar | vector
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
Table data — Data type of table values
Inherit: Same as
output
(default) | Inherit: Inherit from 'Table data'
| double
| single
| int8
| uint8
| int16
| uint16
| int32
| uint32
| int64
| uint64
| fixdt(1,16)
| fixdt(1,16,0)
| fixdt(1,16,2^0,0)
| <data type expression>
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
objectAn 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 two Interpolation 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)' |
'<data type expression>' |
Default:
'Inherit: Same as output' |
Table minimum — Minimum value of table data
[]
(default) | scalar
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:
'[]' |
Table maximum — Maximum value of table data
[]
(default) | scalar
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:
'[]' |
Intermediate results — Data type of intermediate results
Inherit: Inherit via internal rule
(default) | 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)
| <data type expression>
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
objectAn 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)' |
'<data type expression>' |
Default:
'Inherit: Inherit via internal rule' |
Output — Output data type
Inherit: Inherit from 'Table data'
(default) | Inherit: Inherit via back propagation
| double
| single
| int8
| uint8
| int16
| uint16
| int32
| uint32
| int64
| uint64
| fixdt(1,16)
| fixdt(1,16,0)
| fixdt(1,16,2^0,0)
| <data type expression>
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
objectAn 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)' | '<data type
expression>' |
Default:
'Inherit: Inherit from table data' |
Output minimum — Minimum value the block can output
[]
(default) | scalar
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:
'[]' |
Output maximum — Maximum value the block can output
[]
(default) | scalar
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:
'[]' |
Internal rule priority — Internal rule for intermediate calculations
Speed
(default) | Precision
Specify the internal rule for intermediate calculations. Select
Speed
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' |
Lock data type settings against changes by the fixed-point tools — Prevent fixed-point tools from overriding data types
off
(default) | on
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' |
Integer rounding mode — Rounding mode for fixed-point operations
Floor
(default) | Convergent
| Ceiling
| Nearest
| Round
| Simplest
| Zero
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' |
Saturate on integer overflow — Method of overflow action
off
(default) | on
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 |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.
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
Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.
Version History
Introduced in R2006b
See Also
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)
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)