Stateflow® structures enable you to bundle data of different size and type together into a
Simulink.Bus object. Using dot notation and
numeric indices, you can access and modify the contents of a Stateflow structure. For more information, see Access Bus Signals Through Stateflow Structures.
To index substructures and fields of Stateflow structures, use dot notation. The first part of a name identifies the parent
object. Subsequent parts identify the children along a hierarchical path. When the parent is
a structure, its children are individual fields or fields that contain other structures
(also called substructures). The names of the fields of a Stateflow structure match the names of the elements of the
Simulink.Bus object that defines the structure.
For example, the C chart in this model contains an input structure
in, an output structure
out, and a local structure
The fields of the input structure
in and the output structure
out have the same name as the elements of
BusObject that defines them:
c. The field of the local structure
subbus has the
ele as the element of
SubBus. This table lists how the Stateflow chart resolves symbols in dot notation for indexing the fields of these
|Dot Notation||Symbol Resolution|
|First value of the vector field |
|Value in the second row, second column of field |
|Value in the third row, fourth column of field |
In this example, the Stateflow chart uses brackets and zero-based indexing for vectors and arrays because C is the action language for the chart. For more information, see Differences Between MATLAB and C as Action Language Syntax.
You can assign values to any Stateflow structure, substructure, or a field of a structure with a scope different from
To assign one structure to another structure, define both structures from the same
Simulink.Bus object in the base workspace.
To assign one structure to a substructure of a different structure (or vice
versa), define the structure and substructure from the same
To assign a field of one structure to a field of another structure, the fields
must have the same type and size. You can define the Stateflow structures from different
This table presents valid and invalid structure assignments based on the structure specifications for the previous example.
|Assignment||Valid or Invalid?||Explanation|
You cannot write to input structures.
You cannot write to substructures of input structures.
You cannot write to fields of input structures.