Stateflow    

Copying Objects Individually

You can copy specific objects from one object to another. However, in order to preserve transition connections and containment relations between objects, you must copy all the connected objects at once. To accomplish this, use the general technique of appending objects from successive finds in MATLAB to a growing array of objects before copying the finished object array to the Clipboard.

Using the example of the Stateflow chart at the end of Create New Objects in the Chart, you can copy states A1, A2, and the transition connecting them to another state, B, with API commands. Assume that sA and sB are workspace handles to states A and B, respectively.

You can also accomplish the job of constructing the copy array through a complex find command. This might be adequate in certain situations. However, this approach might require you to formulate a very complex command. By contrast, the technique of appending found objects to an array relies on simpler find commands.

You can also copy nongraphical data, events, and target objects individually. However, since there is no way for these objects to find their new owners, you must ensure that each of these objects is separately copied to its appropriate owner object.


  Copying by Grouping (Recommended) Using the Editor Object