Comment Out Objects in a Stateflow Chart
Comment Out a Stateflow Object
Commenting out a Stateflow® object excludes it from simulation. To comment out a Stateflow object, right-click the object and select Comment Out. Use commenting to:
Debug a chart by making minor changes between simulation runs.
Test and verify the effects of objects on simulation results.
Create incremental changes for rapid, iterative design.
How Commenting Affects the Chart and Model
A commented object is not visible to the rest of the chart and the model. Commented objects in a chart are excluded from:
Simulation
Logging
Code generation
Animation
Debugging
Active state output
References to commented functions or states result in compile-time errors.
When you explicitly comment out a Stateflow object with Comment Out, the object appears gray
with a badge . The software implicitly comments out some associated
objects. For example, if you explicitly comment out a state or junction, all incoming and
outgoing transitions are implicitly commented out. Implicitly commented objects also appear
gray, but do not have a badge. For instance, in this chart, the state
steady_state
is explicitly commented. The transitions in and out of
steady_state
are implicitly commented.
To open this example, enter:
openExample("sf_car")
Explicitly Commented Stateflow Object | Implicit Results |
---|---|
States | All incoming and outgoing transitions, and child objects are implicitly commented out. |
Transitions | None |
Junctions | All connected transitions are implicitly commented out. |
Functions | The software cannot invoke a commented function from any chart or model. |
Data | You cannot explicitly comment out data. If you comment out the parent object, then the software cannot reference the data. |
Events | You cannot explicitly comment out events. If you comment out the parent object, then the software cannot reference the event. |
To uncomment an object, right-click the commented object and select Uncomment. All implicitly commented objects are restored as well. Implicitly commented objects cannot be uncommented directly.
Add Text to a Commented Object
Add a note to the commented object by clicking the badge . Point to a badge to see the associated comments. You cannot add notes to implicitly commented objects.
Limitations on Commenting Objects
When you comment out an atomic subchart, the objects inside the chart do not appear implicitly commented. However, a commenting badge is displayed in the lower-left corner of the chart.