This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Commenting Stateflow Objects in a 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

When a chart is parsed, references to commented functions or states result in 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. Implicitly commented objects also appear gray, but do not have a badge. For example, if you explicitly comment out a state or junction, all incoming and outgoing transitions are implicitly commented out. In this image of sf_car, the state steady_state is explicitly commented. The transitions in and out of steady_state are implicitly commented.

Explicitly Commented Stateflow Object Implicit Results
StatesAll incoming and outgoing transitions, and child objects are implicitly commented out.
TransitionsNone
JunctionsAll connected transitions are implicitly commented out.
FunctionsThe software cannot invoke a commented function from any chart or model.
DataYou cannot explicitly comment out data. If you comment out the parent object, then the software cannot reference the data.
EventsYou 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.