Products & Services Solutions Academia Support User Community Company

Learn more about Stateflow   

Working with Transitions in Charts

Creating 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.

Attached transitions obey the following rules:

To delete a transition, click it and select Edit > Cut, or press the Delete key.

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

Straight and Curved Transitions

By default, a transition maintains a straight line whenever possible. To create a curved transition, while clicking and dragging from one state or junction to another, do one of the following:

For curved transitions, the source point remains stationary regardless of where you move the end point.

Labeling Transitions

Transition labels contain Stateflow action language that accompanies the execution of a transition. Creating and editing transition labels is described in the following topics:

For more information on transition concepts, see Transition Label Notation.

For more information on transition label contents, see Using Actions in Stateflow Charts.

Editing Transition Labels

Label unlabeled transitions as follows:

  1. Select (left-click) the transition.

    The transition turns 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 [condition]{condition_action}/transition_action

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

Label Field

Description

event

Event that causes the transition to be evaluated.

condition

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

condition_action

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

transition_action

This action executes after the source state for the transition is exited but before the destination state is entered.

Transitions do not have to have labels. You can specify some, all, or none of the parts of the label. Valid transition labels are defined by the following:

Moving 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. See Setting Smart Behavior in Transitions for a description of smart and nonsmart transition behavior.

Bowing 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.

Moving 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.

Moving 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 the mouse on an empty location in the Stateflow Editor to deselect the label.

Changing 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 from the Transition shortcut menu:

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

  2. Place your pointer over a selected transition and right-click to display the shortcut menu.

    A menu of arrowhead sizes appears.

  3. Select an arrowhead size from the menu.

To adjust arrowhead size from the Junction shortcut menu:

  1. Select the junctions whose incoming arrowhead size you want to change.

  2. Place your pointer over a selected junction and right-click.

  3. In the resulting submenu, place your pointer over Arrowhead Size.

    A menu of arrowhead sizes appears.

  4. Select a size from the menu.

Creating Self-Loop Transitions

A self-loop transition is a transition whose source and destination are the same state or junction. For example, the following figure shows self-loop transitions.

To create a self-loop transition, follow these steps:

  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.

Creating Default Transitions

A default transition is a transition with a destination (a state or a junction), but no apparent source object. See Default Transitions for an explanation of default transitions.

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 Changing Transition Arrowhead Size.

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

Changing Transition Properties

Use the Transition dialog box to view and change the properties for a transition. To access the Transitions dialog box for a particular transition, follow these steps:

  1. Right-click on the transition.

    A context menu appears.

  2. Choose Properties from the context menu.

    The Transition dialog box for the transitions appears.

    The following table lists and describes the properties displayed for a transition in its Transition dialog box:

    Field

    Description

    Source

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

    Destination

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

    Parent

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

    Debugger breakpoints

    Select the check boxes to set debugging breakpoints either when the transition is tested for validity or when it is valid.

    Execution order

    The order in which the transition is executed.

    Label

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

    Description

    Textual description or comment.

    Document Link

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

  3. After making changes, select one of these options:

    • 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.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS