Stateflow    

Defining Data Arrays

To add a data array, do the following:

  1. 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).
  2. Open the Data dialog box.
  3. Select the Array check box on the dialog.
  4. Set the data's Sizes property to the size of each of the array's dimensions. See the Sizes property in Setting Data Properties.
  1. 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].

  1. Set the item's Initial Index property to the index of the array's first element.
  1. For example, to define a zero-based array, set the Initial Index property to 0.

  1. Set the item's initialization source and, if initialized from the data dictionary, initial value.
  1. 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.

  1. 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