Main Content

Stateflow.Transition

Transition in chart, state, box, or function

    Description

    Use Stateflow.Transition objects to create transitions from one operating mode to another. For more information, see Transition Between Operating Modes.

    Creation

    Description

    example

    transition = Stateflow.Transition(parent) creates a Stateflow.Transition object in a parent chart, state, box, or graphical function.

    Input Arguments

    expand all

    Parent for the new transition, specified as a Stateflow® API object of one of these types:

    Properties

    expand all

    Stateflow API objects have properties that correspond to the values you set in the Stateflow Editor. To access or modify a property, use dot notation. To access or modify multiple properties for multiple API objects, use the get and set functions, respectively. For more information, see Modify Properties and Call Functions of Stateflow Objects.

    Content

    Label for the transition, specified as a character vector. For more information, see Specify Labels in States and Transitions Programmatically.

    This property is read-only.

    Transition condition, specified as a character vector. The value of this property depends on the LabelString property for the transition. For more information, see Specify Labels in States and Transitions Programmatically.

    This property is read-only.

    Transition condition action, specified as a character vector. The value of this property depends on the LabelString property for the transition. For more information, see Specify Labels in States and Transitions Programmatically.

    This property is read-only.

    Transition action, specified as a character vector. The value of this property depends on the LabelString property for the transition. For more information, see Specify Labels in States and Transitions Programmatically.

    This property is read-only.

    Transition trigger, specified as a character vector. The value of this property depends on the LabelString property for the transition. For more information, see Specify Labels in States and Transitions Programmatically.

    Execution order for the transition when its source is active, specified as an integer scalar. This property applies only when the UserSpecifiedStateTransitionExecutionOrder property of the chart that contains the transition is true. For more information, see Transition Evaluation Order.

    Whether to comment out the transition, specified as a numeric or logical 1 (true) or 0 (false). Setting this property to true is equivalent to right-clicking the transition and selecting Comment Out. For more information, see Commenting Stateflow Objects in a Chart.

    This property is read-only.

    Whether the transition is implicitly commented out, specified as a numeric or logical 1 (true) or 0 (false). The transition is implicitly commented out when you comment out its source, its destination, or a state, box, or function that contains it.

    Comment text added to the transition, specified as a character vector. This property applies only when the IsExplicitlyCommented property is true. In the Stateflow Editor, when you point to the comment badge on the transition, the text appears as a tooltip. When you set the IsExplicitlyCommented property to false, the value of CommentText reverts to ''.

    Graphical Appearance

    Source of the transition, specified as an empty array or a Stateflow API object of one of these types:

    Position of the transition endpoint at its source, specified as a two-element numeric vector [x y] of coordinates relative to the upper left corner of the chart.

    Location of the transition endpoint at its source, specified as a scalar between 0 and 12 that describes a clock position.

    Destination of the transition, specified as an empty array or a Stateflow API object of one of these types:

    Position of the transition endpoint at its destination, specified as a two-element numeric vector [x y] of coordinates relative to the upper left corner of the chart.

    Location of the transition endpoint at its destination, specified as a scalar between 0 and 12 that describes a clock position.

    Position of the midpoint of the transition, specified as a two-element numeric vector [x y] of coordinates relative to the upper left corner of the chart.

    Position and size of the transition label, specified as a four-element numeric vector of the form [left top width height].

    Size of the transition arrow at the destination, specified as a scalar. When you change the destination of the transition, this property resets to the value of the ArrowSize property of the new destination.

    Font size for the transition label, specified as a scalar. The TransitionFont.Size property of the chart that contains the transition sets the initial value of this property.

    Debugging

    Debugger properties for the transition, specified as a Stateflow.TransDebug object with these properties:

    • Breakpoints.WhenTested — Whether to set the When Transition is Tested breakpoint, specified as a numeric or logical 1 (true) or 0 (false).

    • Breakpoints.WhenValid — Whether to set the When Transition is Valid breakpoint, specified as a numeric or logical 1 (true) or 0 (false).

    For more information, see Set Breakpoints to Debug Charts.

    Example: transition.Debug.Breakpoints.WhenTested = true;

    Example: transition.Debug.Breakpoints.WhenValid = true;

    Code Generation

    Whether the transition is a variant transition, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Code Generation Using Variant Transitions.

    Hierarchy

    This property is read-only.

    Chart that contains the transition, specified as a Stateflow.Chart object.

    This property is read-only.

    Subviewer for the transition, specified as a Stateflow.Chart, Stateflow.State, Stateflow.Box, or Stateflow.Function object. The subviewer is the chart or subchart where you can graphically view the transition.

    This property is read-only.

    Machine that contains the transition, specified as a Stateflow.Machine object.

    This property is read-only.

    Location of the parent of the transition in the model hierarchy, specified as a character vector.

    Identification

    Description for the transition, specified as a character vector.

    Document link for the transition, specified as a character vector.

    User-defined tag for the transition, specified as data of any type.

    This property is read-only.

    Session-independent identifier, specified as an integer scalar. Use this property to distinguish the transition from other objects in the model.

    This property is read-only.

    Unique identifier, specified as an integer scalar. Unlike SSIdNumber, the value of this property is reassigned every time you start a new MATLAB® session and may be recycled after an object is deleted.

    Object Functions

    getParentIdentify parent of object
    dialogOpen properties dialog box
    isCommentedDetermine if graphical object is commented out
    viewDisplay object in editing environment
    highlightHighlight graphical object
    fitToViewZoom in on graphical object

    Examples

    collapse all

    Add a transition that connects state s1 to state s2 in the chart ch.

    transition = Stateflow.Transition(ch);
    transition.Source = s1;
    transition.Destination = s2;

    Add a label that specifies a trigger, condition, and condition action on the transition transition.

    transition.LabelString = 'trigger[guard]{action();}';

    Transition with a trigger, a condition, and a condition action.

    To extract the trigger, condition, and condition action specified by the transition label, enter:

    trigger = transition.Trigger
    trigger =
    
        'trigger'
    condition = transition.Condition
    condition =
    
        'guard'
    action = transition.ConditionAction
    action =
    
        'action();'

    Create a Stateflow.Transition object in the Stateflow.Chart object ch.

    dt = Stateflow.Transition(ch);
    

    Set the destination of the transition to the Stateflow.State object st.

    dt.Destination = st;
    dt.DestinationOClock = 0;

    Place the source endpoint for the transition 30 pixels above the destination endpoint. Place the midpoint for the transition 15 pixels above the destination endpoint.

    dt.SourceEndPoint = dt.DestinationEndPoint-[0 30];
    dt.MidPoint = dt.DestinationEndPoint-[0 15];

    Stateflow chart with a default transition leading to a state.

    Create a supertransition that connects junction j1, which is inside a subchart, to junction j2, which is outside the subchart.

    Stateflow chart with one state. A transition connects a junction inside the state to a junction outside the state.

    Save the original position of subchart st to a temporary workspace variable subchartPosition.

    subchartPosition = st.Position;

    Convert the subchart to a normal state by setting its IsSubchart and IsGrouped properties to false.

    st.IsSubchart = false;
    st.IsGrouped = false;

    When you convert a subchart to a normal state, it may change size to display its contents.

    Stateflow chart with one state. A transition connects a junction inside the state to a junction outside the state.

    Add a transition that connects junction j1 to junction j2 in the chart ch.

    tr = Stateflow.Transition(ch);
    tr.Source = j1;
    tr.Destination = j2;

    Stateflow chart with one subchart. A supertransition connects a junction inside the subchart to a junction outside the subchart.

    Revert the state to a subchart by setting its IsSubchart property to true. Restore the subchart to its original position.

    st.IsSubchart = true;
    st.Position = subchartPosition;

    The state A is now a subchart and the transition between the junctions is now a supertransition.

    Stateflow chart with one subchart. A supertransition connects a junction inside the subchart to a junction outside the subchart.

    For more information, see Move Between Levels of Hierarchy by Using Supertransitions.

    Introduced before R2006a