Stateflow    

Copying by Grouping (Recommended)

Copying a grouped state in Stateflow copies not only the state but all of its contents. By grouping a state before you copy it, you can copy it and all of its contained objects at all levels of containment with the Stateflow API. This is the simplest way of copying objects and should be used whenever possible.

You use the boolean IsGrouped property for a state to group that state. If you set the IsGrouped property for a state to a value of true (=1), it is grouped. If you set IsGrouped to a value of false (=0), the state is not grouped.

The following example procedure copies state A to the chart X through grouping. In this example, assume that you already have a handle to state A and chart X through the MATLAB variables sA and chX, respectively.

  1. If the state to copy is not already grouped, group it along with all its contents by setting the IsGrouped property for that state to true (=1).
  2. Get a handle to the Clipboard object.
  3. Copy the grouped state to the clipboard using the Clipboard object.
  4. Paste the grouped object to its new container.
  5. Set the copied state and its source state to its previous IsGrouped property value.

  copy Method Limitations Copying Objects Individually