| Contents | Index |
| On this page… |
|---|
Setting Behavior for a Reenabled Chart |
If you define a function-call input event for a chart, you can control the behavior of states when this event reenables the chart:
Open the Chart properties dialog box.
For States When Enabling, select one of these options:
Held — Maintain most recent values of the states.
Reset — Revert to the initial values of the states.
Inherit — Inherit this setting from the parent subsystem.
| If... | The inherited setting is... |
|---|---|
The parent of the chart is the model root | Held |
The chart is inside a Model block | Reset For more information, see Referencing a Model in the Simulink documentation. |
For new charts, the default setting is Held.
When the parent of your chart is the model root, the following types of behavior can occur when a function-call input event reenables the chart.
| The chart... | When you set the States When Enabling property to... |
|---|---|
| Maintains the most recent values of the states | Inherit or Held |
| Reverts to the initial values of the states | Reset |
In the following model, the Caller chart uses the event E to wake up and execute the Callee chart.

The Caller chart contains two states, A and B.

When you bind E to A:
Entering A enables the Callee chart.
Exiting A disables the Callee chart.
Reentering A reenables the Callee chart.
Each time the Callee chart executes, the output data y increments by one.

In the Chart properties dialog box for Callee, States When Enabling is Inherit. Because the parent of this chart is the model root, the chart maintains the most recent values of all states when reenabled.
During simulation, Callee maintains the most recent value of its state when the function-call input event reenables the chart at t = 20 and 40.

The key behaviors are:
| Time Interval | Caller Chart | Callee Chart |
|---|---|---|
| 0 – 10 | State A is active and enables Callee. | State A executes by incrementing y. |
| 10 – 20 | State B is active and disables Callee. | State A does not execute. |
| 20 – 30 | State A is active and reenables Callee. | State A executes by incrementing y. |
| 30 – 40 | State B is active and disables Callee. | State A does not execute. |
| 40 – 50 | State A is active and reenables Callee. | State A executes by incrementing y. |
If States When Enabling is Held, the output is the same.
Suppose that the States When Enabling property is Reset for Callee. During simulation, Callee reverts to the initial value of its state when the function-call input event reenables the chart at t = 20 and 40.

When your chart is inside a Model block, the following types of behavior can occur when a function-call input event reenables the chart.
| The chart... | When you set the States When Enabling property to... |
|---|---|
| Maintains the most recent values of the states | Held |
| Reverts to the initial values of the states | Inherit or Reset |
The following model contains a Model block and a scope. (For more information about using Model blocks, see Referencing a Model in the Simulink documentation.)

The Model block contains the Caller and Callee charts from Behavior When the Parent Is the Model Root.

In the Chart properties dialog box for Callee, States When Enabling is Inherit. Because this chart is inside a Model block, the chart reverts to the initial values of all states when reenabled.
During simulation, Callee reverts to the initial value of its state when the function-call input event reenables the chart at t = 20 and 40.

The key behaviors are:
| Time Interval | Caller Chart | Callee Chart |
|---|---|---|
| 0 – 10 | State A is active and enables Callee. | State A executes by incrementing y. |
| 10 – 20 | State B is active and disables Callee. | State A does not execute. |
| 20 – 30 | State A is active and reenables Callee. | State A executes by incrementing y. |
| 30 – 40 | State B is active and disables Callee. | State A does not execute. |
| 40 – 50 | State A is active and reenables Callee. | State A executes by incrementing y. |
If States When Enabling is Reset, the output is the same.
Suppose that the States When Enabling property is Held for Callee. During simulation, Callee maintains the most recent value of its state when the function-call input event reenables the chart at t = 20 and 40.

![]() | Using Input Events to Activate a Stateflow Chart | Using Output Events to Activate a Simulink Block | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |