Stateflow User's Guide Previous page   Next Page

Access the Model Object

In the Stateflow API, each model you create or load into memory is represented by an object of type Model. Before accessing the Stateflow chart you created in the previous section, you must first connect to its Model object. However, in the Stateflow API, all Model objects are contained by the Stateflow API Root object, so you must use the Root object returned by the method sfroot to access a Model object:

  1. Use the following command to obtain a handle to the Root object:
  2. Use the handle to the Root object, rt, to find the Model object representing your new untitled Simulink model and assign it a handle, m in the following command:

If, instead of one model, there are several models open, this command returns an array of different Model objects that you could access through indexing (m(1),m(2),...). You can identify a specific Model object using the properties of each model, particularly the Name property, which is the name of the model. For example, you can use the Name property to find a Model object 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 Model object for the model 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.


Previous page  Create a New Model and Chart Access the Chart Object Next page

© 1994-2005 The MathWorks, Inc.