jc_0491: Reuse of variables within a single Stateflow scope

ID: Title

jc_0491: Reuse of variables within a single Stateflow scope

Priority

Recommended

Scope

MAAB

MATLAB Versions

All

Prerequisites

None

Description

The same variable should not have multiple meanings (usages) within a single Stateflow state.

Correct

Variable of loop counter must not be used other than loop counter.

Incorrect

The meaning of the variable i changes from the index of the loop counter to the sum of a+b.

Correct

tempVar is defined as local scope in both SubState_A and SubState_B.

Rationale

  • Readability

  • Verification

  • Code Generation

Last Changed

V2.2

Model Advisor Check

By Task > Modeling Standards for MAAB > Stateflow > Check reuse of Variables within a Stateflow scope

For check details, see Check reuse of variables within a Stateflow scope (Simulink Check).

Introduced in R2010a