Skip to Main Content Skip to Search
Product Documentation

Making Supertransitions

The Stateflow API does not currently support the direct creation of supertransitions. Supertransitions are transitions between a state or junction in a top-level chart and a state or junction in one of its subcharts, or between states residing in different subcharts at the same or different levels in a chart. For a better understanding of supertransitions, see What Is a Supertransition? in the Stateflow documentation.

You can use a workaround for indirectly creating supertransitions. In this example, a supertransition is desired from a junction inside a subchart to a junction outside the subchart. In order to use the Stateflow API to create the supertransition in this example, first use the API to create the superstate as an ordinary state with a transition between its contained junction and a junction outside it.

Now set the IsSubchart property of the state A to true (=1).

This step makes state A a subchart, and the transition between the junctions is now a supertransition.

You can also connect supertransitions to and from objects in an existing subchart (state A, for example) with these steps:

  1. Save the original position of subchart A to a temporary workspace variable.

    For example, if the subchart A has the API handle sA, store its position with this command:

    sA_pos = sA.Position;
    
  2. Convert subchart A to a state by setting the IsSubchart property to false (=0).

    sA.IsSubchart = 0;

  3. Ungroup state A by setting the IsGrouped property to false (=0).

    sA.IsGrouped = 0;

    When you convert a subchart to a normal state, it stays grouped to hide the contents of the subchart. When you ungroup the subchart, it might resize to display its contents.

  4. Make the necessary transition connections.

    See Creating New Objects in the Chart for an example of creating a transition.

  5. Set the IsSubchart property of state A back to true (=1).

    For example, sA.IsSubchart = 1;

  6. Assign subchart A its original position.

    sA.Position = sA_pos;

    When you convert a subchart to a normal state and ungroup it, it might resize to accommodate the size of its contents. The first step of this procedure stores the original position of the subchart so that this position can be restored after the transition connection is made.

  


Free Stateflow Interactive Kit

Learn how engineers use Stateflow to model state machines in their Simulink models.


Get free kit

Trials Available

Try the latest version of Stateflow.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS