Add data when you want to store values that are visible at 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 chart. Actions in your chart can refer to internal and external data.
Data defined in a Stateflow chart can be used by multiple Stateflow objects in the chart, such as states, MATLAB® functions and truth tables. Stateflow data is not available to Simulink functions within Stateflow.
If you have unused data in your chart, a warning appears during simulation with a list of data 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 data, except for the following types:
Inputs and outputs of MATLAB functions
Data of parameter scope in a chart that contains atomic subcharts
After you select data 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:
You can control the level of diagnostic action for unused data in the Diagnostics > Stateflow pane of the Model Configuration Parameters dialog box. For more information, see the documentation for the Unused data, events and messages diagnostic.
Based on the desired scope for the new data, select one of the following options:
|Input||Chart > Add Inputs & Outputs > Data Input From Simulink|
|Output||Chart > Add Inputs & Outputs > Data Output To Simulink|
|Local||Chart > Add Other Elements > Local Data|
|Constant||Chart > Add Other Elements > Constant|
|Parameter||Chart > Add Other Elements > Parameter|
|Data Store Memory||Chart > Add Other Elements > Data Store Memory|
The Data properties dialog box appears after you select one of those options.
Specify properties for the new data in the Data properties dialog box, as described in Set Data Properties.
In the Stateflow Editor, select View > Model Explorer.
The Model Explorer opens.
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 new data.
In the Model Explorer, select Add > Data.
The Model Explorer adds a default definition for the data in the hierarchy, and the data definition appears in a new row in the Model Explorer.
Change the properties of the data, as described in Set Data Properties.