Stateflow |
 |
Defining Data Arrays
To add a data array, do the following:
- Add a default data item to the data dictionary as a child of the state, chart, or machine that needs to access the data (see Adding Data to the Data Dictionary).
- Open the Data dialog box.
- Select the Array check box on the dialog.
- Set the data's Sizes property to the size of each of the array's dimensions. See the Sizes property in Setting Data Properties.
- For example, to define a 100-element vector, set the Sizes property to
100
. To define a 2-by-4 array, set the Sizes property to [2 4]
.
- Set the item's Initial Index property to the index of the array's first element.
- For example, to define a zero-based array, set the Initial Index property to
0
.
- Set the item's initialization source and, if initialized from the data dictionary, initial value.
- For example, to specify that an array's elements be initialized to zero, set the Initialize from option in the Data dialog box to
data dictionary
and enter 0
in the adjacent text field.
- Set the other options in the dialog box (for example, Name, Type, and so on) to reflect the data item's intended usage.
Suppose that you want to define a local, 4-by-4, zero-based array of type Integer
named rotary_switches
. Further, suppose that each element of the array is initially 1 and can have no values less than 1 or greater than 10. The following Data dialog box shows the settings for such an array.

| Setting Data Properties | | Defining Input Data |  |