Main Content

db_0125: Stateflow local data

Since R2020a

Guideline Publication

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

Sub ID Recommendations

  • NA-MAAB — a, b, c, d

  • JMAAB — a, b, c, d

MATLAB Versions

All

Rule

Sub ID a

Data objects shall not be defined with Scope set to Local at the machine level.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Scope has set Local local data at the machine level.

Sub ID b

Data objects shall not be defined with Scope set to Constant at the machine level.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Scope has set Constant local data at the machine level.

Sub ID c

Data objects shall not be defined with Scope set to Parameter at the machine level.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Scope has set Parameter local data at the machine level.

Sub ID d

A Stateflow block with parent-child relationships shall not include stateflow data with the same name.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

A Stateflow block with parent-child relationships has local data with the same name.

Rationale

Sub ID a:

  • When local data is defined at the machine level, it is shared with all blocks in the model. The data will not behave like a local variable and can be influenced by any operation.

  • Adherence to the rules prevent the definition from disappearing when copying a Stateflow block to another model.

Sub IDs b, c:

  • Adherence to the rules prevent the definition from disappearing when copying a Stateflow block to another model.

Sub ID d:

  • When a Stateflow block with parent-child relationships includes stateflow data with the same name, readability decreases due to lack of clarity with regard to the influence of the stateflow data.

Verification

Model Advisor check: Check definition of Stateflow data (Simulink Check)

Last Changed

R2024b

Version History

Introduced in R2020a