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
Input Arguments
parent
— Parent for new transition
Stateflow.Chart
object | Stateflow.State
object | Stateflow.Box
object | Stateflow.Function
object
Parent for the new transition, specified as a Stateflow® API object of one of these types:
Properties
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
LabelString
— Label for transition
""
(default) | string scalar | character vector
Label for the transition, specified as a string scalar or character vector. For more information, see Specify Labels in States and Transitions Programmatically.
Condition
— Transition condition
character vector
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.
ConditionAction
— Transition condition action
character vector
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.
TransitionAction
— Transition action
character vector
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.
Trigger
— Transition trigger
character vector
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.
ExecutionOrder
— Execution order for transition
scalar
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.
IsExplicitlyCommented
— Whether to comment out transition
false
or 0 (default) | true
or 1
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 Comment Out Objects in a Stateflow Chart.
IsImplicitlyCommented
— Whether transition is implicitly commented out
true
or 1 | false
or 0
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 explicitly comment out an object that contains it or
when you comment out its source or destination. If the transition is contained in an
atomic subchart or an atomic box, this property is false
unless the
explicitly commented object is also contained in the atomic subchart or atomic
box.
IsCommented
— Whether transition is commented out
true
or 1 | false
or 0
Since R2023a
This property is read-only.
Whether the transition is commented out, specified as a numeric or logical 1
(true
) or 0 (false
). This property is
true
when either IsExplicitlyCommented
or
IsImplicitlyCommented
is true
.
CommentText
— Comment text
""
(default) | string scalar | character vector
Comment text added to the transition, specified as a string scalar or 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
— Source of transition
[]
(default) | Stateflow.AtomicSubchart
object | Stateflow.Junction
object | Stateflow.SimulinkBasedState
object | Stateflow.State
object
Source of the transition, specified as an empty array or a Stateflow API object of one of these types:
SourceEndpoint
— Position of transition endpoint at source
[2 2]
(default) | [x y]
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.
SourceOClock
— Location of transition endpoint at source
0
(default) | scalar between 0 and 12
Location of the transition endpoint at its source, specified as a scalar between 0 and 12 that describes a clock position.
Destination
— Destination of transition
[]
(default) | Stateflow.AtomicSubchart
object | Stateflow.Junction
object | Stateflow.SimulinkBasedState
object | Stateflow.State
object
Destination of the transition, specified as an empty array or a Stateflow API object of one of these types:
DestinationEndPoint
— Position of transition endpoint at destination
[40 40]
(default) | [x y]
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.
DestinationOClock
— Location of transition endpoint at destination
0
(default) | scalar between 0 and 12
Location of the transition endpoint at its destination, specified as a scalar between 0 and 12 that describes a clock position.
MidPoint
— Position of midpoint of transition
[21 21]
(default) | [x y]
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.
LabelPosition
— Position and size of transition label
[0 0 8 14]
(default) | [left top width height]
Position and size of the transition label, specified as a four-element numeric
vector of the form [left top width height]
.
ArrowSize
— Size of transition arrow
scalar
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.
FontSize
— Font size for transition label
scalar
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
Debug
— Debugger properties
Stateflow.TransDebug
object
Debugger properties for the transition, specified as a Stateflow.TransDebug
object with
these properties:
Breakpoints.WhenTested
— Whether to set theWhen Transition is Tested
breakpoint, specified as a numeric or logical 1 (true
) or 0 (false
).Breakpoints.WhenValid
— Whether to set theWhen 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
IsVariant
— Whether transition is a variant transition
false
or 0 (default) | true
or 1
Whether the transition is a variant transition, specified as a numeric or logical
1 (true
) or 0 (false
). For more information, see
Control Indicator Lamp Dimmer Using Variant Conditions.
Hierarchy
Chart
— Chart that contains transition
Stateflow.Chart
object
This property is read-only.
Chart that contains the transition, specified as a
Stateflow.Chart
object.
Subviewer
— Subviewer for transition
Stateflow.Chart
object | Stateflow.State
object | Stateflow.Box
object | Stateflow.Function
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.
Machine
— Machine that contains transition
Stateflow.Machine
object
This property is read-only.
Machine that contains the transition, specified as a Stateflow.Machine
object.
Path
— Location of parent in model hierarchy
character vector
This property is read-only.
Location of the parent of the transition in the model hierarchy, specified as a character vector.
Identification
Description
— Description
""
(default) | string scalar | character vector
Description for the transition, specified as a string scalar or character vector.
Document
— Document link
""
(default) | string scalar | character vector
Document link for the transition, specified as a string scalar or character vector.
Tag
— User-defined tag
[]
(default) | any data type
User-defined tag for the transition, specified as data of any type.
SSIdNumber
— Session-independent identifier
scalar
This property is read-only.
Session-independent identifier, specified as an integer scalar. Use this property to distinguish the transition from other objects in its parent chart.
Id
— Unique identifier
scalar
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
Examples
Add Transition to Chart
Add a transition that connects state s1
to state
s2
in the chart ch
.
transition = Stateflow.Transition(ch); transition.Source = s1; transition.Destination = s2;
Label Transitions
Add a label that specifies a trigger, condition, and condition action on the
transition transition
.
transition.LabelString = "trigger[guard]{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();'
Add a Default Transition
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];
Add Supertransition from Subchart
Create a supertransition that connects a junction inside a subchart to a junction outside the subchart.
Open the model and access the Stateflow.Chart
object for the chart.
open_system("sfSupertransitionAPIExample") ch = find(sfroot,"-isa","Stateflow.Chart");
Access the Stateflow.State
object for the subchart and the Stateflow.Junction
objects for the junctions.
st = find(ch,"-isa","Stateflow.State"); j1 = find(st,"-isa","Stateflow.Junction"); j2 = find(ch,"-isa","Stateflow.Junction","-depth",1);
Save the original position of the subchart 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.
Add a transition that connects junction j1
to junction j2
.
tr = Stateflow.Transition(ch); tr.Source = j1; tr.Destination = j2;
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 transition between the junctions is now a supertransition that crosses the boundary of the subchart.
Version History
Introduced before R2006aR2023a: New object function and property
Use the object function commentedBy
and the property
IsCommented
to investigate commented-out transitions:
The object function
commentedBy
identifies the explicitly commented objects that cause a transition to be commented out.The property
IsCommented
indicates whether a transition is commented out. This property replaces the object functionisCommented
.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)