| Stateflow User's Guide |
 |
Adding Data to the Data Dictionary
You can use either the Stateflow editor or Explorer to add data that is accessible only in a specific chart. You must use the Stateflow Explorer to add data that is accessible everywhere in a Stateflow chart or in a specific object such as a state.
Adding Data in the Stateflow Diagram Editor
If you add events in the Stateflow diagram editor, they are parented by the Stateflow diagram and are visible to all objects in the chart. To add an event in the Stateflow diagram editor, do the following:
- From the Add menu of the Stateflow editor, select Event.
- The Data properties dialog appears.
- In the resulting pop-up menu, select one of the following scopes for this data:
- Local -- Data is defined for use in this Stateflow diagram only.
- Constant -- Data is defined as a constant.
- Input from Simulink -- The Simulink model provides the value for this data by an input port to the Stateflow block for this diagram.
- Output to Simulink -- Stateflow provides this data to the Simulink model by an output port on the Stateflow block for this diagram.
- Parameter -- Data is defined as a constant whose value is taken from a parameter for the parent masked Simulink subsystem or from the MATLAB base workspace variable of the same name. See The Mask Editor in Simulink documentation for information on how to assign a parameter to a masked subsystem.
- Stateflow adds a default definition of the new event to the Stateflow data dictionary and displays the Data dialog box.
- Specify properties for the data specified in the Data dialog box.
- See Setting Data Properties in the Data Dialog for a description of the property fields of the Data dialog box.
Adding Data in the Model Explorer
If you add events in the Model Explorer, you can choose any Stateflow object to parent the new event. This event is visible to the parent object and all child objects of the parent. To add an event in the Model Explorer, do the following:
- Select Explore from the Stateflow editor's Tools menu.
- The Model Explorer opens.

If no object is selected, the current diagram or subchart is highlighted in the Model Hierarchy pane of the Model Explorer. Otherwise, the selected object is highlighted. In the preceding example, state Off is selected in the Stateflow diagram myChart when the Model Explorer is called.
- Select the object (machine, chart, or state) in the object hierarchy pane where you want the new data to be visible.

- In the preceding example, the Stateflow chart myChart is selected to receive the new event.
- From the Add menu of the Model Explorer, select Data.
- Stateflow adds a default definition for the new data in the data dictionary and displays an entry row for the new data in the Explorer's Contents pane.

- Change the properties of the event in one of the following ways:
- To change the Name, Scope, Trigger Type, or Port property for the event, click individual entries in the entry row in the Model Explorer.
- To change any or all properties for the event, right-click the event row and select Properties to access the Data dialog for the event.
| Adding Data | | Defining Temporary Data |  |
© 1994-2005 The MathWorks, Inc.