Using Stateflow     Search    Help Desk 

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" on page 3-14).
   2.
Open the Data properties dialog. Check the Array checkbox 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].
   3.
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.
   4.
Set the item's Initial Value property to an appropriate value.
For example, to specify that an array's elements be initialized to zero, set the Initial Value property to 0.
   5.
Set the item's other properties (e.g., Name, Type, and so on) to reflect its 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 table shows the data property settings for such an array.

Property
Value
Name
rotary_switches
Scope
Local
Type
Integer
Sizes
[4 4]
First Index
0
Initial Value
1
Minimum
1
Maximum
10



[ Previous | Help Desk | Next ]