Stateflow.AtomicSubchart
Atomic subchart in chart, state, or box
Description
Use Stateflow.AtomicSubchart
objects to create independent
subcomponents in a Stateflow® chart. Atomic subcharts allow for:
Reuse of the same state or subchart across multiple charts and models
Faster simulation after making small changes to a chart with many states or levels of hierarchy
Ease of team development when multiple people are working on different parts of the same chart
Manual inspection of generated code for a specific state or subchart in a chart
For more information, see Create Reusable Subcomponents by Using Atomic Subcharts.
Creation
Description
Input Arguments
parent
— Parent for new atomic subchart
Stateflow.Chart
object | Stateflow.State
object | Stateflow.Box
object
Parent for the new atomic subchart, 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
Name
— Name of atomic subchart
""
(default) | string scalar | character vector
Name of the atomic subchart, specified as a string scalar or character vector.
LabelString
— Label for atomic subchart
"?"
(default) | string scalar | character vector
Label for the atomic subchart, specified as a string scalar or character vector.
IsLink
— Whether atomic subchart is a library link
true
or 1 | false
or 0
This property is read-only.
Whether the atomic subchart is a library link, specified as a numeric or logical 1
(true
) or 0 (false
).
IsExplicitlyCommented
— Whether to comment out atomic subchart
false
or 0 (default) | true
or 1
Whether to comment out the atomic subchart, specified as a numeric or logical 1
(true
) or 0 (false
). Setting this property to
true
is equivalent to right-clicking the atomic subchart and
selecting Comment Out. For more information, see Comment Out Objects in a Stateflow Chart.
IsImplicitlyCommented
— Whether atomic subchart is implicitly commented out
true
or 1 | false
or 0
This property is read-only.
Whether the atomic subchart is implicitly commented out, specified as a numeric or
logical 1 (true
) or 0 (false
). The atomic
subchart is implicitly commented out when you explicitly comment out an object that
contains it. If the atomic subchart is contained in another atomic subchart, this
property is false
unless the explicitly commented object is also
contained in the atomic subchart.
IsCommented
— Whether atomic subchart is commented out
true
or 1 | false
or 0
Since R2023a
This property is read-only.
Whether the atomic subchart 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 for the atomic subchart, 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 atomic subchart, the text appears as a
tooltip. When you set the IsExplicitlyCommented
property to
false
, the value of CommentText
reverts to
""
.
Graphical Appearance
Position
— Position and size of atomic subchart
[0 0 90 60]
(default) | [left top width height]
Position and size of the atomic subchart, specified as a four-element numeric vector of
the form [left top width height]
.
BadIntersection
— Whether atomic subchart intersects a box, state, or function
true
or 1 | false
or 0
This property is read-only.
Whether the atomic subchart graphically intersects a box, state, or function, specified
as a numeric or logical 1 (true
) or 0
(false
).
ContentPreviewEnabled
— Whether to display preview of atomic subchart contents
false
or 0 (default) | true
or 1
Whether to display a preview of the atomic subchart contents, specified as a
numeric or logical 1 (true
) or 0 (false
).
ArrowSize
— Size of incoming transition arrows
8
(default) | scalar
Size of incoming transition arrows, specified as a scalar.
FontSize
— Font size for atomic subchart label
scalar
Font size for the atomic subchart label, specified as a scalar. The
StateFont.Size
property of the chart that contains the atomic
subchart sets the initial value of this property.
State Decomposition
Type
— Decomposition of sibling states
'AND'
| 'OR'
This property is read-only.
Decomposition of sibling states, specified as 'AND'
or
'OR'
. The atomic subchart inherits this property from the
Decomposition
property of its parent state or chart.
ExecutionOrder
— Execution order in parallel (AND) decomposition
scalar
Execution order for the atomic subchart in parallel (AND) decomposition, specified as an integer scalar. This property applies only when both of these conditions are satisfied:
The
Type
property of the atomic subchart is"AND"
.The
UserSpecifiedStateTransitionExecutionOrder
property of the chart that contains the atomic subchart istrue
.
Active State Output
HasOutputData
— Whether to create active state data output
false
or 0 (default) | true
or 1
Whether to create an active state data output port for the atomic subchart,
specified as a numeric or logical 1 (true
) or 0
(false
). For more information, see Monitor State Activity Through Active State Data.
OutputData
— Active state data object
Stateflow.Data
object
This property is read-only.
Active state data object for the atomic subchart, specified as a Stateflow.Data
object. This property applies only when the
HasOutputData
property for the atomic subchart is
true
.
OutputPortName
— Name of active state data object
string scalar | character vector
Name of the active state data object for the atomic subchart, specified as a
string scalar or character vector. This property applies only when the
HasOutputData
property for the atomic subchart is
true
.
OutputMonitoringMode
— Monitoring mode for active state output
"SelfActivity"
Monitoring mode for the active state output data, specified as a string scalar or
character vector. For atomic subcharts, the only option is
"SelfActivity"
.
Signal Logging and Test Point Monitoring
LoggingInfo
— Signal logging properties
Stateflow.SigLoggingInfo
object
Signal logging properties for the atomic subchart, specified as a Stateflow.SigLoggingInfo
object
with these properties:
DataLogging
— Whether to enable signal logging, specified as a numeric or logical 1 (true
) or 0 (false
).DecimateData
— Whether to limit the amount of logged data, specified as a numeric or logical 1 (true
) or 0 (false
).Decimation
— Decimation interval, specified as an integer scalar. This property applies only when theDecimateData
property istrue
.LimitDataPoints
— Whether to limit the number of data points to log, specified as a numeric or logical 1 (true
) or 0 (false
).MaxPoints
— Maximum number of data points to log, specified as an integer scalar. This property applies only when theLimitDataPoints
property istrue
.NameMode
— Source of the signal name, specified as"SignalName"
or"Custom"
.LoggingName
— Custom signal name, specified as a string scalar or character vector. This property applies only when theNameMode
property is"Custom"
.
Signal logging saves the self activity of the atomic subchart to the MATLAB® workspace during simulation. For more information, see Log Simulation Output for States and Data.
Example: state.LoggingInfo.DataLogging = true;
TestPoint
— Whether to set atomic subchart as test point
false
or 0 (default) | true
or 1
Whether to set the atomic subchart as a test point, specified as a numeric or
logical 1 (true
) or 0 (false
). You can monitor
testpoints with a floating scope during simulation. You can also log test point values
to the MATLAB workspace. For more information, see Monitor Test Points in Stateflow Charts.
Debugging
Debug
— Debugger properties
Stateflow.StateDebug
object
Debugger properties for the state, atomic subchart, or Simulink® based state, specified as a Stateflow.StateDebug
object with
these properties:
OnEntry
— Whether to set theOn State Entry
breakpoint, specified as a numeric or logical 1 (true
) or 0 (false
).OnDuring
— Whether to set theDuring State
breakpoint, specified as a numeric or logical 1 (true
) or 0 (false
).OnExit
— Whether to set theOn State Exit
breakpoint, specified as a numeric or logical 1 (true
) or 0 (false
).
For more information, see Set Breakpoints to Debug Charts.
Example: atomicSubchart.Debug.Breakpoints.OnEntry =
true;
Example: atomicSubchart.Debug.Breakpoints.OnDuring =
true;
Example: atomicSubchart.Debug.Breakpoints.OnExit =
true;
Hierarchy
Chart
— Chart that contains atomic subchart
Stateflow.Chart
object
This property is read-only.
Chart that contains the atomic subchart, specified as a
Stateflow.Chart
object.
Subchart
— Contents of atomic subchart
Stateflow.Chart
object
This property is read-only.
Contents of the atomic subchart, specified as a Stateflow.Chart
object. Use this object to add children, such as states and transitions, to the atomic
subchart. For more information, see Add Exit Port and Junction to Atomic Subchart.
Subviewer
— Subviewer for atomic subchart
Stateflow.Chart
object | Stateflow.State
object | Stateflow.Box
object
This property is read-only.
Subviewer for the atomic subchart, specified as a
Stateflow.Chart
, Stateflow.State
, or
Stateflow.Box
object. The subviewer is the chart or subchart where
you can graphically view the atomic subchart.
Machine
— Machine that contains atomic subchart
Stateflow.Machine
object
This property is read-only.
Machine that contains the atomic subchart, 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 atomic subchart in the model hierarchy, specified as a character vector.
Identification
Description
— Description
""
(default) | string scalar | character vector
Description for the atomic subchart, specified as a string scalar or character vector.
Document
— Document link
""
(default) | string scalar | character vector
Document link for the atomic subchart, specified as a string scalar or character vector.
Tag
— User-defined tag
[]
(default) | any data type
User-defined tag for the atomic subchart, 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 atomic subchart from other objects in the model.
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
getParent | Identify parent of object |
getReferences | Identify references to symbol name |
renameReferences | Rename symbol and update references to symbol name |
commentedBy | Identify objects that implicitly comment out a graphical object |
getMappingForSymbol | Get mapping for symbol in atomic subchart, atomic box, or Simulink based state |
setMappingForSymbol | Set mapping for symbol in atomic subchart, atomic box, or Simulink based state |
clearMappingForSymbol | Clear mapping for symbol in atomic subchart, atomic box, or Simulink based state |
disableMappingForSymbol | Disable input event in atomic subchart or box |
dialog | Open properties dialog box |
view | Display object in editing environment |
highlight | Highlight graphical object |
fitToView | Zoom in on graphical object |
Examples
Add Atomic Subchart to Chart
Add an atomic subchart in the chart ch
. Set its name to
A
.
atomicSubchart = Stateflow.AtomicSubchart(ch);
atomicSubchart.Name = "A";
Add Exit Port and Junction to Atomic Subchart
Since R2021b
In an atomic subchart called A
, add an exit port
and an exit junction with the label "exit"
.
Find the Stateflow.AtomicSubchart
object that corresponds to the
atomic subchart A
in the chart ch
.
atomicSubchart = find(ch,"-isa","Stateflow.AtomicSubchart",Name="A");
Add an exit junction to the atomic subchart. Use the Subchart
property of the atomic subchart as the parent of the exit junction. Display the
value of the PortType
property of the exit junction.
exitJunction = Stateflow.Port(atomicSubchart.Subchart,"ExitJunction");
exitJunction.PortType
ans = 'ExitJunction'
Set the label of the exit junction to "exit"
.
exitJunction.labelString = "exit";
Find the Stateflow.Port
object for the matching exit port.
Display the value of the PortType
property of the exit
port.
exitPort = Stateflow.findMatchingPort(exitJunction); exitPort.PortType
ans = 'ExitPort'
Display the label of the exit port.
exitPort.labelString
ans = 'exit'
Map Variables in Atomic Subchart
Since R2022b
In an atomic subchart called A
, modify the mapping for the subchart input u1
.
Open the model sf_atomic_iodata_fixed.slx
.
open_system("sf_atomic_iodata_fixed")
Access the Stateflow.AtomicSubchart
object for the atomic subchart A
.
subsystem = find(sfroot,"-isa","Stateflow.AtomicSubchart", ... Name="A");
Use the Subchart
property to access the Stateflow.Data
object for subchart input u1
.
subsystemSymbol = find(subsystem.Subchart, ... "-isa","Stateflow.Data",Name="u1");
Use the Chart
property to access the Stateflow.Data
object for chart input u2
.
chartSymbol = find(subsystem.Chart, ... "-isa","Stateflow.Data",Name="u2");
Check the mapping for subchart input u1
.
getMappingForSymbol(subsystem,subsystemSymbol).Name
ans = 'u1'
Map subchart input u1
to chart input u2
.
setMappingForSymbol(subsystem,subsystemSymbol,chartSymbol) getMappingForSymbol(subsystem,subsystemSymbol).Name
ans = 'u2'
Clear the mapping for subchart input u1
.
clearMappingForSymbol(subsystem,subsystemSymbol) getMappingForSymbol(subsystem,subsystemSymbol).Name
ans = 'u1'
Version History
Introduced in R2010bR2023a: New object functions and properties
Stateflow.AtomicSubchart
objects have new object functions and properties:
The object function
getReferences
returns the locations where a chart refers to the name of an atomic subchart.The object function
renameReferences
renames an atomic subchart and updates all references to the atomic subchart name in the chart.The object function
commentedBy
identifies the explicitly commented objects that cause an atomic subchart to be commented out.The property
IsCommented
indicates whether an atomic subchart is commented out. This property replaces the object functionisCommented
.
R2022b: Map variables for atomic subcharts
Edit the mapping of atomic subchart symbols by calling the object functions getMappingForSymbol
, setMappingForSymbol
, clearMappingForSymbol
, and
disableMappingForSymbol
.
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 (한국어)