| Stateflow® | ![]() |
| On this page… |
|---|
Add data when you want to define data that is visible to a specific level of the Stateflow® hierarchy.
You can store and retrieve data that resides internally in the Stateflow workspace, and externally in the Simulink® model or application that embeds the Stateflow chart. Stateflow actions can reference internal and external data.
To add data using the Stateflow Editor, follow these steps:
In the pop-up menu, select a scope for the new data object.
See Scope for a description of each type of scope.
Selecting scope adds a default definition of the new data object to the Stateflow hierarchy and displays the Data properties dialog.
Specify properties for the new data object in the Data properties dialog, as described in Setting Data Properties in the Data Dialog.
If you add data in the Stateflow Editor, that data is visible to all objects in the chart.
To add data using the Model Explorer, follow these steps:
In the Stateflow Editor, select Tools > Explore.
The Model Explorer opens. If no object is selected, the current chart or subchart appears highlighted in the Model Hierarchy pane. Otherwise, the selected object appears highlighted.
In the Model Hierarchy pane, select the object in the Stateflow hierarchy where you want the new data to be visible.
The object you select becomes the parent of the data object.
In the Model Explorer, select Add > Data, or click the Add Data button:
![]()
This action adds a default definition for the data in the hierarchy, and the data definition appears in a new row in the Model Explorer Contents pane.

Change the properties of the data, as described in Setting Data Properties in the Data Dialog.
In the Model Explorer, you can add data that is visible at these levels in the Stateflow hierarchy:
Stateflow machine
Stateflow chart
Box
State
Subchart
Substate
Function
Stateflow charts can contain graphical, truth table, and Embedded MATLAB™ functions.
Stateflow objects that can parent data in the model hierarchy appear in this diagram.

![]() | Defining Data | Setting Data Properties in the Data Dialog | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |