Stateflow | ![]() ![]() |
Access the Machine Object
In the Stateflow API, each model you create or load into memory is represented by an object of type Machine. Before accessing the Stateflow chart you created in the previous section, you must first connect to its Machine (model) object. However, in the Stateflow API all Machine objects are contained by the Stateflow API Root object, so you must access the Root object first.
rt
now becomes a handle to the Stateflow API Root object. Now that you have a handle, rt
, to the Root object, you can use it to access the Machine object representing the new untitled Simulink model as follows:
m
, as follows:
If, instead of one model, there are several models open, the preceding command returns an array of different machine objects that you could access through indexing (m(1)
,m(2)
,...). You can identify a specific machine object using the properties of each machine, particularly the Name
property, which is the name of the model. For example, you can use the Name
property to find a machine with the name "myModel" with the following command:
However, since you now have only one model loaded, the object handle m
in the command for step 2 returns the machine that you just created. You are now ready to use m
to access the empty Stateflow chart so that you can start filling it with Stateflow objects.
![]() | Create a New Model and Chart | Access the Chart Object | ![]() |