jc_0802: Prohibited use of implicit type casting in Stateflow
Since R2020a
Guideline Publication
Control Algorithm Modeling Guidelines - Using MATLAB®, Simulink®, and Stateflow®
Sub ID Recommendations
NA-MAAB — a
JMAAB — a
MATLAB Versions
All
Rule
Sub ID a
All operations, including substitution, comparison, arithmetic, etc., shall be performed between variables of the same data type.
The data type of the actual arguments and the formal arguments in a function call shall be the same.
Not Applicable
Variables use the same data type for calculations.
Example: Comparison operation
Example: Arithmetic operations and assignment operations (compound expressions)
Variables have different data types but are explicitly typecast before calculation.
Example: Comparison operation
Example: Arithmetic operations and assignment operations (compound expressions)
The data type of actual arguments and formal arguments in the function call are the same.
Variables use different data types for calculations.
Example: Comparison operation
Example: Arithmetic operations and assignment operations (compound expressions)
Calculations are performed between unsigned integer type variables and signed integers.
The data type of actual arguments and formal arguments in the function call are different.
Rationale
Sub ID a:
Implicit data type conversion can produce unexpected results.
Verification
Model Advisor check: Check for implicit type casting in Stateflow (Simulink Check)
Last Changed
R2020a
See Also
Type Cast Operations (Stateflow)
Differences Between MATLAB and C as Action Language Syntax (Stateflow)
Version History
Introduced in R2020a