Stateflow    

Defining Data Arrays

Stateflow allows you to define arrays of data.

To define an array:

  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. Check the Array check box on the dialog. Set the item's Sizes property to the size of each of the array's dimensions (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].

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

  1. 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 Initialized from option in the Data dialog box to data dictionary and the enter 0 in the adjacent text field.

  1. Set the other options in the dialog box (e.g., Name, Type, and so on) to reflect the data item's intended usage.

Example

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 was initially 1 and could have no values less than 1 or greater than 10. The following Data dialog box shows the settings for such an array.


 Data Dialog Box Defining Input Data