| Contents | Index |
| On this page… |
|---|
An event is a Stateflow object that can trigger actions in one of these objects:
A Simulink triggered subsystem
A Simulink function-call subsystem
A Stateflow chart
Use events when you want to:
Activate a Simulink triggered subsystem (see Using Edge Triggers to Activate a Simulink Block)
Activate a Simulink function-call subsystem (see Using Function Calls to Activate a Simulink Block)
Trigger actions in parallel states of a Stateflow chart (see Broadcasting Events to Synchronize States)
Although Stateflow software does not limit the number of events you can use in a chart, the underlying C compiler enforces a theoretical limit of (2^31)-1 events for the generated code.
When should I use conditions instead of events?
An explicit event is an event that you define and can have one of the following scopes.
| Scope | Description |
|---|---|
| Local | Event that can occur anywhere in a Stateflow machine but is visible only in the parent object (and descendants of the parent). See Directed Event Broadcasting. |
| Input from Simulink | Event that occurs in a Simulink block but is broadcast to a Stateflow chart. See Using Input Events to Activate a Stateflow Chart. |
| Output to Simulink | Event that occurs in a Stateflow chart but is broadcast to a Simulink block. See Using Output Events to Activate a Simulink Block. |
An implicit event is a built-in event that broadcasts automatically during chart execution (see Using Implicit Events).
You can define explicit events at these levels of the Stateflow hierarchy.
| An event you define in a... | Is visible to... |
|---|---|
| Chart | The chart and all states and substates |
| Subchart | The subchart and all states and substates |
| State | The state and all substates |
If you have unused events in your chart, a warning message appears during simulation with a list of events you can remove. By removing objects that have no effect on simulation, you can reduce the size of your model. This diagnostic checks for usage of Stateflow events, except for the following types:
Function-call input events
Edge-triggered input events
After you select an event for removal, a dialog box confirms your choice. In this dialog box, you can specify that other deletions occur without confirmation. If you prevent the confirmation dialog box from appearing, you can reenable it at any time by typing at the command prompt:
sfpref('showDeleteUnusedConfGui', 1)You can control the level of diagnostic action for unused events in the Diagnostics > Stateflow pane of the Configuration Parameters dialog box. For more information, see the documentation for the Unused data and events diagnostic.
![]() | Defining Events | How to Define Events | ![]() |

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 |