himl_0011: Data type and size of condition expressions
ID: Title | himl_0011: Data type and size of condition expressions |
---|---|
Description | Logical scalars should be used for condition expressions. Condition expressions include:
|
Rationale | Prevent execution of unexpected code paths |
Model Advisor Checks | Check type and size of condition expressions (Simulink Check) |
References |
|
Last Changed | R2019b |
Examples | Recommended Assume
variable MATLAB Code:
if var > 0 % expression is a logical scalar … % will not be executed elseif var < 0 % expression is a logical scalar … % will be executed else … % will not be executed end while var < 5 % expression is a logical scalar var = var + 1; % executed 5 times end Stateflow Transition Condition:
[var > 0]{…} % condition action will not be executed Not Recommended Assume variable
MATLAB Code:
if var % expression is a double scalar … % will be executed because var is non-zero elseif ~var … % will not be executed else … % will not be executed end while var % expression is a double scalar var = var + 1; % executed 1 time end Stateflow Transition Condition:
[var]{…} % condition action will be executed because var is non-zero |