Main Content

2-D Lookup Table

Approximate two-dimensional function

  • 2-D Lookup Table block

Libraries:
Simulink / Lookup Tables
HDL Coder / Lookup Tables

Description

Supported Block Operations

The 1-D, 2-D, and n-D Lookup Table blocks evaluate a sampled representation of a function in N variables

y=F(x1,x2,x3,...,xN)

where the function F can be empirical. The block maps inputs to an output value by looking up or interpolating a table of values you define with block parameters. The block supports flat (constant), linear (linear point-slope), Lagrange (linear Lagrange), nearest, cubic-spline, and Akima spline interpolation methods. You can apply these methods to a table of any dimension from 1 through 30.

In the following block, the first input identifies the first dimension (row) breakpoints, the second input identifies the second dimension (column) breakpoints, and so on.

See Identify Port Location on Rotated or Flipped Block for a description of the port order for various block orientations.

When the Math and Data Types > Use algorithms optimized for row-major array layout configuration parameter is set, the 2-D and n-D Lookup Table block behavior changes from column-major to row-major. For these blocks, the column-major and row-major algorithms may differ in the order of the output calculations, possibly resulting in slightly different numerical values. This capability requires a Simulink® Coder™ or Embedded Coder® license. For more information on row-major support, see Code Generation of Matrices and Arrays (Simulink Coder).

Specification of Breakpoint and Table Data

These block parameters define the breakpoint and table data.

Block ParameterPurpose
Number of table dimensions Specifies the number of dimensions of your lookup table.
Breakpoints Specifies a breakpoint vector that corresponds to each dimension of your lookup table.
Table data Defines the associated set of output values.

Tip

Evenly spaced breakpoints can make the generated code division-free. For more information, see fixpt_evenspace_cleanup and Identify questionable fixed-point operations (Embedded Coder).

How the Block Generates Output

The n-D, 1-D and 2-D Lookup Table blocks generate output by looking up or estimating table values based on the input values.

Block Inputsn-D Lookup Table Block Behavior
Match the values of indices in breakpoint vectorsOutputs the table value at the intersection of the row, column, and higher dimension breakpoints
Do not match the values of indices in breakpoint vectors, but are within rangeInterpolates appropriate table values, using the Interpolation method you select
Do not match the values of indices in breakpoint vectors, and are out of rangeExtrapolates the output value, using the Extrapolation method you select

Other Blocks That Perform Equivalent Operations

You can use the Interpolation Using Prelookup block with the Prelookup block to perform the equivalent operation of one n-D Lookup Table block. This combination of blocks offers greater flexibility that can result in more efficient simulation performance for linear interpolations.

When the lookup operation is an array access that does not require interpolation, use the Direct Lookup Table (n-D) block. For example, if you have an integer value k and you want the kth element of a table, y = table(k), interpolation is unnecessary.

Examples

expand all

This example shows how to use the n-D Lookup Table block to create a logarithm lookup table. The lookup table allows you to approximate the common logarithm (base 10) over the input range [1,10] without performing an expensive computation.

Extended Examples

Ports

Input

expand all

Real-valued inputs to the u1 port, mapped to an output value by looking up or interpolating the table of values that you define.

Example: 0:10

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | enumerated | fixed point

Real-valued inputs to the u2 port, mapped to an output value by looking up or interpolating the table of values that you define.

Example: 0:10

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | enumerated | fixed point

Specify the table of output values with a signal that is tunable at runtime.

During simulation, the matrix size must match the dimensions defined by the Number of table dimensions parameter and the breakpoint lengths for each dimension of the table. However, during block diagram editing, you can enter an empty matrix (specified as []) or an undefined workspace variable. This technique lets you postpone specifying a correctly dimensioned matrix for the table data and continue editing the block diagram.

Dependencies

To enable this port, set:

  • Data specification to Table and breakpoints.

  • Table data to Input port.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Specify the breakpoint data explicitly, based on the value of the Breakpoints specification parameter, with a signal that is tunable at runtime.

  • If you set Breakpoints specification to Explicit values, enter the breakpoint vector that corresponds to each dimension of table data in each Breakpoints row. For each dimension, specify breakpoints as a 1-by-n or n-by-1 vector whose values are strictly monotonically increasing.

Note

To specify breakpoints in the even spacing specification format, set Breakpoints specification to Even spacing and use the Breakpoints First point and Spacing parameters.

Dependencies

To enable this port, set:

  • Data specification to Table and breakpoints.

  • Breakpoints specification to Explicit values.

  • Breakpoints 1 to Input port.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | enumerated | fixed point

Specify the breakpoint data explicitly, based on the value of the Breakpoints specification parameter, with a signal that is tunable at runtime.

  • If you set Breakpoints specification to Explicit values, enter the breakpoint vector that corresponds to each dimension of table data in each Breakpoints row. For each dimension, specify breakpoints as a 1-by-n or n-by-1 vector whose values are strictly monotonically increasing.

Note

To specify evenly spaced breakpoint data, use the Breakpoints parameter. You cannot specify evenly spaced breakpoint data through the input port.

Dependencies

To enable this port, set:

  • Data specification to Table and breakpoints.

  • Breakpoints specification to Explicit values.

  • Breakpoints 2 to Input port.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | enumerated | fixed point

Output

expand all

Output generated by looking up or estimating table values based on the input values.

When block inputs...The n-D Lookup Table block...
Match the values of indices in breakpoint vectorsOutputs the table value at the intersection of the row, column, and higher dimension breakpoints
Do not match the values of indices in breakpoint vectors, but are within rangeInterpolates appropriate table values, using the Interpolation method you select
Do not match the values of indices in breakpoint vectors, and are out of rangeExtrapolates the output value, using the Extrapolation method you select

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Parameters

expand all

Table and Breakpoints

Enter the number of dimensions of the lookup table. This parameter determines:

  • The number of independent variables for the table and the number of block inputs

  • The number of breakpoint vectors to specify

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.

For example, a table with a size of M x N x ... means that the size of dimension 1 is M, the size of dimension 2 is N, and so forth. M must match the first breakpoint length, N must match the second breakpoint length, and so forth.

Programmatic Use

Block Parameter: NumberOfTableDimensions
Type: character vector
Values: '1' | '2' | '3' | '4' | ... | 30
Default: '2'

From the list, select:

  • Table and breakpoints — Specify the table data and breakpoints. Selecting this option enables these parameters:

    • Table data

    • Breakpoints specification

    • Breakpoints 1

    • Breakpoints 2

    • Edit table and breakpoints

    To specify the table and breakpoints using input ports, see the Source parameter.

  • Lookup table object — Use an existing lookup table (Simulink.LookupTable) object. Selecting this option enables the Name field and Edit table and breakpoints button.

Programmatic Use

Block Parameter: DataSpecification
Type: character vector
Values: 'Table and breakpoints' | 'Lookup table object'
Default: 'Table and breakpoints'

To set this parameter from 'Table and breakpoints' to 'Lookup table object', use the same set_param call to set the LookupTableObject parameter. For example:

set_param('myModel/myLookupBlock',...
   'DataSpecification','Lookup table object',...
   'LookupTableObject','myLUTObject')

Enter the name of the lookup table (Simulink.LookupTable) object. 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 Data specification to Lookup table object.

Programmatic Use

Block Parameter: LookupTableObject
Type: character vector
Values: name of a Simulink.LookupTable object
Default: ''

Specify whether to enter data as explicit breakpoints or as parameters that generate evenly spaced breakpoints.

  • To explicitly specify breakpoint data, set this parameter to Explicit values and enter breakpoint data in the text box next to the Breakpoints parameters.

  • To specify parameters that generate evenly spaced breakpoints, set this parameter to Even spacing and enter values for the First point and Spacing parameters for each dimension of breakpoint data. The block calculates the number of points to generate from the table data.

Dependencies

To enable this parameter, set Data specification to Table and breakpoints.

Programmatic Use

Block Parameter: BreakpointsSpecification
Type: character vector
Values: 'Explicit values' | 'Even spacing'
Default: 'Explicit values'

Select this check box to enable tunable table size in simulation and in the generated code. This option allows you to change the size and values of the lookup table and breakpoint data in the generated code without regenerating or recompiling the code. You can only decrease the size of the lookup table and breakpoint data.

Dependencies

If you set Interpolation method to Cubic spline, Support tunable size is not available.

Programmatic Use

Block Parameter: SupportTunableSize
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Source of table and breakpoint data, specified as:

  • Dialog — Specify the table or breakpoint data in Value parameter.

  • Input port — Specify the table or breakpoint data through the associated input port. Through the input port, you can specify only up to three sets of breakpoint data. To specify breakpoint data above three, use the Value parameter.

Note

Using the input port to specify table or breakpoint data might negatively affect block performance for simulation due to runtime checks.

Dependencies

  • To enable this parameter, set Data specification to Table and breakpoints.

  • To enable the associated Value, set this parameter to Dialog.

  • To enable the associated input port, set this parameter to Input port.

  • Setting this parameter to Input port disables the Value field and hides the corresponding parameter on the Data Types tab.

  • Setting this parameter to Input port for any one of the parameters disables the Edit Table and Breakpoints button.

Programmatic Use

Block Parameter: TableSource | BreakpointsForDimension1Source | BreakpointsForDimension2Source | BreakpointsForDimension3Source
Type: character vector
Values: Dialog | Input port
Default: 'Dialog'

Specify the maximum size of each array as one of these values:

  • -1 — All of the elements in the array

  • Real integer scalar — Maximum number of elements for each array

Tunable size must be less than or equal to the size of the array.

Dependencies

To enable this parameter:

  • Set Data specification to Table and breakpoints.

  • Select the Support tunable size parameter.

Programmatic Use

Block Parameter: N1 to N31
Type: character vector
Values: -1 | real integer scalar
Default: -1

Enter the table of output values in the associated Value field.

During simulation, the matrix size must match the dimensions defined by the Number of table dimensions parameter. However, during block diagram editing, you can enter an empty matrix (specified as []) or an undefined workspace variable. This technique lets you postpone specifying a correctly dimensioned matrix for the table data and continue editing the block diagram.

Dependencies

To enable this parameter, set:

  • Data specification to Table and breakpoints.

  • Table data: Source to Dialog.

Programmatic Use

Block Parameter: Table
Type: character vector
Values: matrix of table values
Default: '[4 5 6; 16 19 20; 10 18 23]'

Specify the breakpoint data explicitly or as evenly-spaced breakpoints, based on the value of the Breakpoints specification parameter.

  • If you set Breakpoints specification to Explicit values, enter the breakpoint vector that corresponds to each dimension of table data in each Breakpoints row in the associated Value field. For each dimension, specify breakpoints as a 1-by-n or n-by-1 vector whose values are strictly monotonically increasing.

  • If you set Breakpoints specification to Even spacing, enter the parameters First point and Spacing in each Breakpoints row to generate evenly-spaced breakpoints in the respective dimension. Your table data determines the number of evenly spaced points.

Dependencies

  • To enable this parameter, set

    • Data specification to Table and breakpoints.

    • Breakpoints: Source to Dialog.

  • When the Breakpoints specification parameter is set to Even spacing, you can only specify breakpoints data through the dialog box.

Programmatic Use

Block Parameter: BreakpointsForDimension1
Type: character vector
Values: 1-by-n or n-by-1 vector of monotonically increasing values
Default: '[1:3]'

Specify the first point in your evenly spaced breakpoint data as a real-valued, finite, scalar. This parameter is available when Breakpoints specification is set to Even spacing.

Dependencies

To enable this parameter, set Data specification to Table and breakpoints, and Breakpoints specification to Even spacing.

Programmatic Use

Block Parameter: BreakpointsForDimension1FirstPoint | BreakpointsForDimension2FirstPoint
Type: character vector
Values: real-valued, finite, scalar
Default: '1'

Specify the spacing between points in your evenly-spaced breakpoint data.

Dependencies

To enable this parameter, set Data specification to Table and breakpoints, and Breakpoints specification to Even spacing.

Programmatic Use

Block Parameter: BreakpointsForDimension1Spacing | BreakpointsForDimension2Spacing
Type: character vector
Values: positive, real-valued, finite, scalar
Default: '1'

Click this button to open the Lookup Table Editor. For more information, see Edit Lookup Tables.

Clicking this button for a lookup table object lets you edit the object and save the new values for the object.

Algorithm

Lookup method

When an input falls between breakpoint values, the block interpolates the output value using neighboring breakpoints. For more information on interpolation methods, see Interpolation Methods.

Dependencies

  • If you select Cubic spline, the block supports only scalar signals. The other interpolation methods support nonscalar signals.

  • If you select Akima spline, the extrapolation method can only be Akima spline.

    When set to the modified Akima interpolation method, this block does not support:

    • Row-major array layout and algorithms optimized for row-major array layout

    • Scaled double and fixed-point data types

    • Simulink.LookupTable objects

    • Code generation when the configuration parameter Code Generation > Interface > Support non-finite numbers check box is selected

    When set to the modified Akima interpolation method, this block is known to run more slowly when these conditions are true:

    • Code generation-based simulation targets, such as those for accelerator mode, rapid accelerator mode, protected models, and so forth.

    • Code generated for large breakpoint and data table sizes. For example with a table size of 629x1601.

Programmatic Use

Block Parameter: InterpMethod
Type: character vector
Values: 'Linear point-slope' | 'Flat' | 'Nearest' | 'Linear Lagrange' | 'Cubic spline' | 'Akima spline'
Default: 'Linear point-slope'

Select Clip, Linear, or Cubic spline. 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.

Dependencies

  • To select Cubic spline for Extrapolation method, you must also select Cubic spline for Interpolation method.

  • To select Akima spline for Extrapolation method, you must also select Akima spline for Interpolation method.

Programmatic Use

Block Parameter: ExtrapMethod
Type: character vector
Values: 'Linear' | 'Clip' | 'Cubic spline' | 'Akima spline'
Default: 'Linear'

Select Evenly spaced points, Linear search, or Binary search. Each search method has speed advantages in different circumstances:

  • For evenly spaced breakpoint vectors (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.

    Note

    Set Index search method to Evenly spaced points when using the Simulink.LookupTable object to specify table data and the Breakpoints Specification parameter of the referenced Simulink.LookupTable object is set to Even spacing.

  • For unevenly spaced breakpoint vectors, follow these guidelines:

    • If input signals do not vary much between time steps, selecting Linear search with Begin index search using previous index result produces the best performance.

    • If input signals 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.

Note

The generated code stores only the first breakpoint, the spacing, and the number of breakpoints when:

  • The breakpoint data is not tunable.

  • The index search method is Evenly spaced points.

Programmatic Use

Block Parameter: IndexSearchMethod
Type: character vector
Values: 'Binary search' | 'Evenly spaced points' | 'Linear search'
Default: 'Binary search'

Select this check box to enable an efficient round to nearest implementation when possible. Enabling this option sets the rounding mode to Nearest and adjusts the fraction lengths and intermediate data types to offer a balance between accuracy and efficiency. If an efficient implementation is not possible, the rounding mode, fraction lengths and intermediate data types remain unchanged.

Dependencies

To enable this parameter:

  • Set Number of table dimensions to 2.

  • Set Interpolation method to Linear point-slope.

  • Set Extrapolation method to Clip.

Programmatic Use

Block Parameter: ApplyAccurateEfficientRounding
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Select this check box when you want the block to start its search using the index found at the previous time step. For inputs 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 vectors.

Dependencies

To enable this parameter, set Index search method to Linear search or Binary search.

Programmatic Use

Block Parameter: BeginIndexSearchUsingPreviousIndexResult
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.

Programmatic Use

Block Parameter: DiagnosticForOutOfRangeInput
Type: character vector
Values: 'None' | 'Warning' | 'Error'
Default: 'None'

Use this check box to enable full-precision fixed-point algorithm lookup for linear interpolation lookup when possible. This algorithm generally achieves better precision for hardware-efficient fixed-point rounding modes.

Dependencies

To enable this parameter, set:

  • Number of table dimensions to 1.

  • Interpolation method to Linear point-slope.

  • Extrapolation method to Clip.

Programmatic Use

Block Parameter: ApplyFullPrecisionForLinearInterpolation
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Using this check box, specify the indexing convention that the block uses to address the last element of a breakpoint vector and its corresponding table value. This check box is relevant if the input is equal to or larger than the last element of the breakpoint data. Due to rounding, selecting and clearing this check box may result in differing results for the last breakpoint between simulation and code generation.

Check BoxIndex Used by BlockInterval Fraction
Selected Last element of breakpoint data on the Table and Breakpoints tab 0
Cleared Next-to-last element of breakpoint data on the Table and Breakpoints tab 1

Given an input u within range of a breakpoint vector bp, the interval fraction f, in the range 0≦f<1, is computed as shown below.

Suppose the breakpoint vector is [1 4 5] and input u is 5.5. If you select this check box, the index is that of the last element (5) and the interval fraction is 0. If you clear this check box, the index is that of the next-to-last element (4) and the interval fraction is 1.

Dependencies

To enable this parameter, set:

  • Interpolation method to Linear.

  • Extrapolation method to Clip.

Programmatic Use

Block Parameter: UseLastTableValue
Type: character vector
Values: 'off' | 'on'
Default: 'off'
Input settings

Select this check box to use only one input port that expects a signal that is n elements wide for an n-dimensional table. This option is useful for removing line clutter on a block diagram with many lookup tables.

Note

When you select this check box, one input port with the label u appears on the block.

Programmatic Use

Block Parameter: UseOneInputPortForAllInputData
Type: character vector
Values: 'off' | 'on'
Default: 'off'
Code generation

Specify whether or not to include code that checks for out-of-range input values.

Check BoxResultWhen to Use

on

Generated code does not include conditional statements to check for out-of-range breakpoint inputs.

When the input is out-of-range, it may cause undefined behavior for generated code.

For code efficiency

off

Generated code includes conditional statements to check for out-of-range 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:

  1. Clear the Remove protection against out-of-range index in generated code check box.

  2. Set the Diagnostic for out-of-range input parameter to Error.

  3. Simulate the model in normal mode.

  4. If there are out-of-range errors, fix them to be in range and run the simulation again.

  5. 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 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.

Programmatic Use

Block Parameter: RemoveProtectionInput
Type: character vector
Values: 'off' | 'on'
Default: 'off'

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)

The Data Type Assistant helps you set data attributes. To use the Data Type Assistant, click the Show data type assistant button. For more information, see Specify Data Types Using Data Type Assistant.

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 n-D Lookup Table blocks with different output data types

  • Sharing of custom storage table data in the generated code for blocks with different output data types

Dependencies

To enable this parameter, set Table data from the Table and Breakpoints tab to Dialog.

Programmatic Use

Block Parameter: TableDataTypeStr
Type: character vector
Values: 'Inherit: Inherit from 'Table data'' | 'Inherit: Same as output' | 'double' | 'single' | 'half' | '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'

Specify the minimum value for table data. The default value is [] (unspecified).

Programmatic Use

Block Parameter: TableMin
Type: character vector
Values: scalar
Default: '[]'

Specify the maximum value for table data. The default value is [] (unspecified).

Programmatic Use

Block Parameter: TableMax
Type: character vector
Values: scalar
Default: '[]'

Specify the data type for a set of breakpoint data. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Same as corresponding input

  • The name of a built-in data type, for example, single

  • The name of a data type class, for example, an enumerated data type class

  • 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)

Tip

  • Breakpoints support unordered enumerated data. As a result, linear searches are also unordered, which offers flexibility but can impact performance. The search begins from the first element in the breakpoint.

  • If the Begin index search using previous index result check box is selected, you must use ordered monotonically increasing data. This ordering improves performance.

  • For enumerated data, Extrapolation method must be Clip.

  • The block does not support out-of-range input for enumerated data. When specifying enumerated data, include the entire enumeration set in the breakpoint vector. For example, use the enumeration function.

This is a limitation for using enumerated data with this block:

  • The block does not support out-of-range input for enumerated data. When specifying enumerated data, include the entire enumeration set in the breakpoint vector. For example, use the enumeration function.

The Data Type Assistant helps you set data attributes. To use the Data Type Assistant, click the Show data type assistant button. For more information, see Specify Data Types Using Data Type Assistant.

Tip

Specify a breakpoint data type different from the corresponding input data type for these cases:

  • Lower memory requirement for storing breakpoint data that uses a smaller type than the input signal

  • Sharing of prescaled breakpoint data between two n-D Lookup Table blocks with different input data types

  • Sharing of custom storage breakpoint data in the generated code for blocks with different input data types

Specify the same slope and bias for a breakpoint data type and its corresponding input data type if either of them has a fixed-point data type.

Dependencies

To enable this parameter, set the corresponding Breakpoints parameter from the Table and Breakpoints tab to Dialog.

Programmatic Use

Block Parameter: BreakpointsForDimension1DataTypeStr | BreakpointsForDimension2DataTypeStr| ... | BreakpointsForDimension30DataTypeStr
Type: character vector
Values: 'Inherit: Same as corresponding input' | 'Inherit: Inherit from 'Breakpoint data'' | 'double' | 'single' | 'half' | '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 corresponding input'

Specify the minimum value that a set of breakpoint data can have. The default value is [] (unspecified).

Programmatic Use

Block Parameter: BreakpointsForDimension1Min | BreakpointsForDimension2Min | ... | BreakpointsForDimension30Min
Type: character vector
Values: scalar
Default: '[]'

Specify the maximum value that a set of breakpoint data can have. The default value is [] (unspecified).

Programmatic Use

Block Parameter: BreakpointsForDimension1Max | BreakpointsForDimension2Max | ... | BreakpointsForDimension30Max
Type: character vector
Values: scalar
Default: '[]'

Specify the fraction data type. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Inherit via internal rule

  • 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 the Show data type assistant button. For more information, see Specify Data Types Using Data Type Assistant.

Programmatic Use

Block Parameter: FractionDataTypeStr
Type: character vector
Values: 'Inherit: Inherit via internal rule' | 'double' | 'single' | 'fixdt(1,16,0)'|'<data type expression>'
Default: 'Inherit: Inherit via internal rule'

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 the Show data type assistant button. For more information, see Specify Data Types Using Data Type Assistant.

Tip

Use this parameter to specify higher (or lower) 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,0)' | 'fixdt(1,16,2^0,0)'|'<data type expression>'
Default: 'Inherit: Same as output'

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)

The Data Type Assistant helps you set data attributes. To use the Data Type Assistant, click the Show data type assistant button. For more information, see Specify Data Types Using Data Type Assistant.

Programmatic Use

Block Parameter: OutDataTypeStr
Type: character vector
Values: 'Inherit: Inherit via back propagation' | 'Inherit: Inherit from table data' | 'Inherit: Same as first input' | 'double' | 'single' | 'half' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'int64' | 'uint64' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)'|'<data type expression'
Default: 'Inherit: Same as first input'

Specify the minimum value that the block outputs. The default value is [] (unspecified). Simulink software uses this value to perform:

Programmatic Use

Block Parameter: OutMin
Type: character vector
Values: scalar
Default: '[]'

Specify the maximum value that the block can output. The default value is [] (unspecified). Simulink software uses this value to perform:

Programmatic Use

Block Parameter: OutMax
Type: character vector
Values: scalar
Default: '[]'

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.

Dependencies

This parameter takes effect only when the Intermediate results parameter is set to Inherit: Inherit via internal rule.

Programmatic Use

Block Parameter: InternalRulePriority
Type: character vector
Values: 'Speed' | 'Precision'
Default: 'Speed'

Select to require all inputs to have the same data type.

Programmatic Use

Block Parameter: InputSameDT
Type: character vector
Values: 'off' | 'on'
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'

Specify the rounding mode for fixed-point lookup table calculations that occur during simulation or execution of code generated from the model. For more information, see Rounding Modes (Fixed-Point Designer).

This option does not affect rounding of values of block parameters. Simulink rounds such values to the nearest representable integer value. To control the rounding of a block parameter, enter an expression using a MATLAB® rounding function into the edit field on the block dialog box.

Programmatic Use

Block Parameter: RndMeth
Type: character vector
Values: 'Ceiling' | 'Convergent' | 'Floor' | 'Nearest' | 'Round' | 'Simplest' | 'Zero'
Default: 'Simplest'

ActionReasons for Taking This ActionWhat Happens for OverflowsExample

Select this check box (on).

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 (off).

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 Troubleshoot 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.

Tip

If you save your model as version R2009a or earlier, this check box setting has no effect and no saturation code appears. This behavior preserves backward compatibility.

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.

Programmatic Use

Block Parameter: SaturateOnIntegerOverflow
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Block Characteristics

Data Types

double | enumerated | fixed point | half | integer | single

Direct Feedthrough

yes

Multidimensional Signals

yes

Variable-Size Signals

no

Zero-Crossing Detection

no

More About

expand all

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced in R2011a

expand all