Main Content

jc_0741: Timing to update data used in state chart transition conditions

Since R2020a

Guideline Publication

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

Sub ID Recommendations

  • NA-MAAB — No recommendations

  • JMAAB — a1, a2, b

MATLAB Versions

All

Rule

Sub ID a1

Variables that are used in a state transition condition shall not use state action du to perform an update.

Custom Parameter

Not Applicable

Exceptions

This rule applies exclusively to writing in a state chart with a transition source. The update is not prohibited for parallel states and outside of the chart.

Example — Correct

Example — Correct (for exception)

Example — Incorrect

State action du is used to perform an update.

Sub ID a2

Variables that are used in a state transition condition shall use state action du to perform an update.

Custom Parameter

Not Applicable

Exceptions

This rule applies exclusively to writing in a state chart with a transition source. The update is not prohibited for parallel states and outside of the chart.

Example — Correct

State action du is used to perform an update.

Example — Correct (for exception)

Example — Incorrect

Sub ID b

When the data referenced in a transition condition is updated to du as its source state, mixing updated and non-updated data in the same transition condition is prohibited, except for constants and parameters.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

State action du is used to perform an update. There is a mixture of data to update with State action du(b) and data not updated in2.

Rationale

Sub ID a1:

  • The execution order of the transition condition and implement of during can be difficult to understand, which increases the risk of errors.

Verification

Model Advisor check: Check updates to variables used in state transition conditions (Simulink Check)

Last Changed

R2024b

Version History

Introduced in R2020a