Main Content

jc_0644: Type setting

Since R2020a

Guideline Publication

Control Algorithm Modeling Guidelines - Using MATLAB®, Simulink®, and Stateflow®

Sub ID Recommendations

  • NA-MAAB — No recommendations

  • JMAAB — a

MATLAB Versions

All

Rule

Sub ID a

The data type shall not be set by using a block or Stateflow data when the data type is set by a data object.

Exceptions

  • Inside a reusable function

  • Data Type Conversion block

  • Data types set by using fixdt

  • Boolean or double types

Custom Parameter

Not Applicable

Example — Correct

Type is set the data object.

Rationale

Sub ID a:

  • When the data type is set in a block and it differs from the type setting in the data object, it can be difficult to determine which setting is correct. This can impair readability.

  • When the type is set in the block, maintainability is affected when the signal line type changes.

  • Exceptions:

    • When block structures are identical, differences between input/output data type can result in different C source code that is not reusable. For reusable functions, data types of input/output blocks should be specified at the subsystem level.

    • The Data Type Conversion block is used to explicitly set the data type.

    • When the data type is fixdt (fixed-point), data type must be set individually because each block can have different data points. In this scenario, it is impossible to use only the data object to set the data type.

    • Some block types must be set to Boolean.

      Double type is generally used in plant models and for Rapid Control Prototyping (RCP), therefore it is not within scope of this rule. Embedded software uses double type in specific situations. Use caution when configuring the settings on these blocks to minimize the use of double type.

Verification

Model Advisor check: Check type setting by data objects (Simulink Check)

Last Changed

R2020a

Version History

Introduced in R2020a