| Stateflow® | ![]() |
| On this page… |
|---|
An event is a Stateflow® object that can trigger actions in one of these objects:
A Simulink® triggered or function-call subsystem
A Stateflow chart
Add events when you want to do one of the following:
Activate a Simulink triggered or function-call subsystem
Trigger actions in different states in the same Stateflow chart
An explicit event is an event that you define and can have one of these scopes:
Local — The Stateflow chart broadcasts the event locally.
Input from Simulink — Another Simulink block broadcasts the event to the Stateflow chart.
Output to Simulink — The Stateflow chart broadcasts the event to another Simulink block.
An implicit event is a built-in event that broadcasts automatically during chart execution (see Using Implicit Events).
The visibility of events in the Stateflow hierarchy is as follows:
| Event Defined In | Visible To |
|---|---|
| Stateflow machine | All Stateflow charts in the model, along with their states and substates |
| Stateflow chart | The chart, along with all states and substates |
| State | The state and all substates |
In the Stateflow Editor, you can add events to your Stateflow chart. Follow these steps:
In the resulting submenu, select the scope for the event.
The Stateflow Editor adds a default definition of the new event to the Stateflow hierarchy, and the Event properties dialog box appears.
Specify properties for the event in the Event properties dialog box, as described in Setting Event Properties in the Event Dialog.
To add events using the Model Explorer, follow these steps:
In the Stateflow Editor, select Tools > Explore.
The Model Explorer appears.
In the Model Explorer, select the object in the Stateflow hierarchy where you want the new event to be visible.
The object you select becomes the parent of the event.
Select Add > Event, or click the Add Event button:
![]()
The Model Explorer adds a default definition for the new event in the hierarchy and displays an entry row for the new event in the Contents pane, as in this example.

Change the properties of the event you add in one of these ways:
Right-click the event row and select Properties to open the Event properties dialog.
See Setting Event Properties in the Event Dialog for a description of each property for an event.
Click individual cells in the entry row to set specific properties such as Name, Scope, and Port.
![]() | Defining Events | Setting Event Properties in the Event Dialog | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |