| Stateflow User's Guide | ![]() |
Creating Stateflow Objects
You create a Stateflow object as the child of a parent object through API constructor methods. Each Stateflow object type has its own constructor method. See Constructor Methods for a list of the valid constructor methods.
Use the following process to create Stateflow objects with the Stateflow API:
See also Accessing Existing Stateflow Objects for a more general means of accessing (getting an object handle to) an existing Stateflow object.
s to a new state object in the chart object with the handle ch:
By default, the newly created state from the preceding command appears in the upper left-hand corner of the Stateflow chart (at x-y coordinates 0,0).
The constructor returns a handle to an API object for the newly created Stateflow object. Use this handle to display or change the object through its properties and methods.
s to set its name (Name property) and position (Position property). You can also connect it to other states or junctions by creating a Transition object and setting its Source or Destination property to s. See Create New Objects in the Chart for examples.
Use the preceding process to create all Stateflow objects in your chart. The section Create New Objects in the Chart gives examples for creating states and transitions. Objects of other types are created just as easily. For example, the following command creates and returns a handle (d1) for a new Data object belonging to the state A (handle sA):
Note
Currently, there is no constructor for a Stateflow chart. To create a chart with the Stateflow API you must use the sfnew objectless method. See Objectless Methods for a description.
|
| Creating and Destroying API Objects | Establishing an Object's Parent (Container) | ![]() |
© 1994-2005 The MathWorks, Inc.