Main Content

Transition Between Operating Modes

A transition is a line with an arrowhead that links one graphical object to another. In most cases, a transition represents the passage of the system from one mode (state) to another. A transition typically connects a source and a destination object. The source object is where the transition begins and the destination object is where the transition ends. For more information, see Transitions.

Create a Transition

Follow these steps to create transitions between states and junctions:

  1. Place your pointer on or close to the border of a source state or junction. The pointer changes to crosshairs.

  2. Click and drag a transition to a destination state or junction.

  3. Release on the border of the destination state or junction.

Alternatively, in the object palette, click the Transition icon . Then, on the chart canvas, click the location for the new transition. If necessary, drag the endpoints of the transition to the source and destination.

Attached transitions obey the following rules:

  • Transitions do not attach to the corners of states. Corners are used exclusively for resizing.

  • Transitions exit a source and enter a destination at angles perpendicular to the source or destination surface.

  • All transitions have smart behavior.

To delete a transition, click it and press the Delete key.

See the following sections for help with creating self-loop and default transitions:

Label Transitions

Transition labels contain syntax that accompanies the execution of a transition. The following topics discuss creating and editing transition labels:

Edit Transition Labels

Label unlabeled transitions as follows:

  1. Select (left-click) the transition.

    The transition changes to its highlight color and a question mark (?) appears on the transition. The ? character is the default empty label for transitions.

  2. Left-click the ? to edit the label.

    You can now type a label.

To apply and exit the edit, deselect the object. To reedit the label, simply left-click the label text near the character position you want to edit.

Transition Label Format

Transition labels have the following general format:

event_or_message [condition]{condition_action}/transition_action

Specify, as appropriate, relevant names for event_or_message, condition, condition_action, and transition_action.

Label Field



The event or message that causes the transition to be evaluated.


Defines what, if anything, has to be true for the condition action and transition to take place.


If the condition is true, the action specified executes and completes.


This action executes after the source state for the transition is exited but before the destination state is entered. Transition actions are not supported in standalone Stateflow® charts in MATLAB®.

Transitions do not need labels. You can specify some, all, or none of the parts of the label. Rules for writing valid transition labels include:

  • Can have any alphanumeric and special character combination, with the exception of embedded spaces

  • Cannot begin with a numeric character

  • Can have any length

  • Can have carriage returns in most cases

  • Must have an ellipsis (...) to continue on the next line

Move Transitions

You can move transition lines with a combination of several individual movements. These movements are described in the following topics:

In addition, transitions move along with the movements of states and junctions.

Bow the Transition Line

You can move or "bow" transition lines with the following procedure:

  1. Place your pointer on the transition at any point along the transition except the arrow or attach points.

  2. Click and drag your pointer to move the transition point to another location.

    Only the transition line moves. The arrow and attachment points do not move.

  3. Release the mouse button to specify the transition point location.

The result is a bowed transition line. Repeat the preceding steps to move the transition back into its original shape or into another shape.

Move Transition Attach Points

You can move the source or end points of a transition to place them in exact locations as follows:

  1. Place your pointer over an attach point until it changes to a small circle.

  2. Click and drag your pointer to move the attach point to another location.

  3. Release the mouse button to specify the new attach point.

The appearance of the transition changes from a solid to a dashed line when you detach and release a destination attach point. Once you attach the transition to a destination, the dashed line changes to a solid line.

The appearance of the transition changes to a default transition when you detach and release a source attach point. Once you attach the transition to a source, the appearance returns to normal.

Move Transition Labels

You can move transition labels to make the Stateflow chart more readable. To move a transition label, do the following:

  1. Click and drag the label to a new location.

  2. Release the left mouse button.

If you mistakenly click and then immediately release the left mouse button on the label, you will be in edit mode for the label. Press the Esc key to deselect the label and try again. You can also click an empty location in the chart to deselect the label.

Change Transition Arrowhead Size

The arrowhead size is a property of the destination object. Changing one of the incoming arrowheads of an object causes all incoming arrowheads to that object to be adjusted to the same size. The arrowhead size of any selected transitions, and any other transitions ending at the same object, is adjusted.

To adjust arrowhead size:

  1. Select the transitions whose arrowhead size you want to change.

  2. Place your pointer over a selected transition and right-click to select Arrowhead Size.

  3. Select an arrowhead size from the menu.

Create Self-Loop Transitions

A self-loop transition is a transition whose source and destination are the same state or junction. To create a self-loop transition:

  1. Create the transition by clicking and dragging from the source state or junction.

  2. Press the S key or right-click your mouse to enable a curved transition.

  3. Continue dragging the transition tip back to a location on the source state or junction.

For the semantics of self-loops, see Self-Loop Transitions.

Create Default Transitions

A default transition is a transition with a destination (a state or a junction), but no apparent source object.

Click the Default Transition button in the toolbar and click a location in the drawing area close to the state or junction you want to be the destination for the default transition. Drag your pointer to the destination object to attach the default transition.

The size of the endpoint of the default transition is proportional to the arrowhead size. See Change Transition Arrowhead Size.

Default transitions can be labeled just like other transitions. See Label Default Transitions for an example.

Change Transition Properties

Use the Transition properties dialog box to view and change the properties for a transition. To access the dialog box for a particular transition:

  1. Right-click the transition and select Properties.

    The Transition properties dialog box appears.

    The following transition properties appear in the dialog box:




    Source of the transition; read-only; click the hypertext link to bring the transition source to the foreground.


    Destination of the transition; read-only; click the hypertext link to bring the transition destination to the foreground.


    Parent of this state; read-only; click the hypertext link to bring the parent to the foreground.

    Execution order

    The order in which the chart executes the transition.


    The transition's label. See Transition Labels for more information on valid label formats.


    Textual description or comment.

    Document link

    Enter a Web URL address or a general MATLAB command. Examples are, mailto:email_address, and edit/spec/data/speed.txt.

  2. After making changes, click one of these buttons:

    • Apply to save the changes and keep the Transition dialog box open.

    • Cancel to return to the previous settings for the dialog box.

    • OK to save the changes and close the dialog box.

    • Help to display Stateflow online help in an HTML browser window.

See Also

Related Topics