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 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 of the atomic subchart, specified as a string scalar or character vector.
Label for the atomic subchart, specified as a string scalar or character vector.
This property is read-only.
Whether the atomic subchart is a library link, specified as a numeric or logical 1
(true
) or 0 (false
).
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.
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.
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
.
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 and size of the atomic subchart, specified as a four-element numeric vector of
the form [left top width height]
.
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
).
Whether to display a preview of the atomic subchart contents, specified as a
numeric or logical 1 (true
) or 0 (false
).
Size of incoming transition arrows, specified as a 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
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.
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
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.
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
.
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
.
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
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;
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 Configure Signals as Test Points (Simulink).
Debugging
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
This property is read-only.
Chart that contains the atomic subchart, specified as a
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.
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.
This property is read-only.
Machine that contains the atomic subchart, specified as a Stateflow.Machine
object.
This property is read-only.
Location of the parent of the atomic subchart in the model hierarchy, specified as a character vector.
Identification
Description for the atomic subchart, specified as a string scalar or character vector.
Document link for the atomic subchart, specified as a string scalar or character vector.
User-defined tag for the atomic subchart, 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 atomic subchart 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
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 an atomic subchart in the chart ch
. Set its name to
A
.
atomicSubchart = Stateflow.AtomicSubchart(ch);
atomicSubchart.Name = "A";
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'
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 R2010bStateflow.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
.
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: United States.
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)