Stateflow.SimulinkBasedState
Simulink based state in chart, state, or box
Description
Use Stateflow.SimulinkBasedState
objects to create Simulink® subsystems within a Stateflow® state. With Simulink based states, you can model hybrid dynamic systems or systems that switch
between periodic and continuous time dynamics. For more information, see Simulink Subsystems as States.
Creation
Description
Input Arguments
parent
— Parent for new Simulink based state
Stateflow.Chart
object | Stateflow.State
object | Stateflow.Box
object
Parent for the new Simulink based state, 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 Simulink based state
""
(default) | string scalar | character vector
Name of the Simulink based state, specified as a string scalar or character vector.
IsExplicitlyCommented
— Whether to comment out Simulink based state
false
or 0 (default) | true
or 1
Whether to comment out the Simulink based state, specified as a numeric or logical 1
(true
) or 0 (false
). Setting this property to
true
is equivalent to right-clicking the Simulink based state and selecting Comment Out. For
more information, see Comment Out Objects in a Stateflow Chart.
IsImplicitlyCommented
— Whether Simulink based state is implicitly commented out
true
or 1 | false
or 0
This property is read-only.
Whether the Simulink based state is implicitly commented out, specified as a numeric or
logical 1 (true
) or 0 (false
). The Simulink based state is implicitly commented out when you explicitly comment out
an object that contains it. If the Simulink based state is contained in an atomic subchart, this property is
false
unless the explicitly commented object is also contained in
the atomic subchart.
IsCommented
— Whether Simulink based state is commented out
true
or 1 | false
or 0
Since R2023a
This property is read-only.
Whether the Simulink based state 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 Simulink based state, 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 Simulink based state, 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 Simulink based state
[0 0 90 60]
(default) | [left top width height]
Position and size of the Simulink based state, specified as a four-element numeric vector of the
form [left top width height]
.
BadIntersection
— Whether Simulink based state intersects a box, state, or function
true
or 1 | false
or 0
This property is read-only.
Whether the Simulink based state graphically intersects a box, state, or function, specified as a
numeric or logical 1 (true
) or 0 (false
).
ContentPreviewEnabled
— Whether to display preview of Simulink based state contents
true
or 1 (default) | false
or 0
Whether to display a preview of the Simulink based state 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 Simulink based state label
scalar
Font size for the Simulink based state label, specified as a scalar. The
StateFont.Size
property of the chart that contains the
Simulink based state 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 Simulink based state 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 Simulink based state 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 Simulink based state is"AND"
.The
UserSpecifiedStateTransitionExecutionOrder
property of the chart that contains the Simulink based state 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 Simulink based state, 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 Simulink based state, specified as a Stateflow.Data
object. This property applies only when the
HasOutputData
property for the Simulink based state is true
.
OutputPortName
— Name of active state data object
string scalar | character vector
Name of the active state data object for the Simulink based state, specified as a string scalar or character vector. This
property applies only when the HasOutputData
property for the
Simulink based state 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 Simulink based states, the only option is
"SelfActivity"
.
Signal Logging and Test Point Monitoring
LoggingInfo
— Signal logging properties
Stateflow.SigLoggingInfo
object
Signal logging properties for the Simulink based state, 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 Simulink based state 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 Simulink based state as test point
false
or 0 (default) | true
or 1
Whether to set the Simulink based state 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 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: simulinkBasedState.Debug.Breakpoints.OnEntry =
true;
Example: simulinkBasedState.Debug.Breakpoints.OnDuring =
true;
Example: simulinkBasedState.Debug.Breakpoints.OnExit =
true;
Hierarchy
Chart
— Chart that contains Simulink based state
Stateflow.Chart
object
This property is read-only.
Chart that contains the Simulink based state, specified as a Stateflow.Chart
object.
Subviewer
— Subviewer for Simulink based state
Stateflow.Chart
object | Stateflow.State
object | Stateflow.Box
object
This property is read-only.
Subviewer for the Simulink based state, specified as a Stateflow.Chart
,
Stateflow.State
, or Stateflow.Box
object. The
subviewer is the chart or subchart where you can graphically view the Simulink based state.
Machine
— Machine that contains Simulink based state
Stateflow.Machine
object
This property is read-only.
Machine that contains the Simulink based state, 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 Simulink based state in the model hierarchy, specified as a character vector.
Identification
Description
— Description
""
(default) | string scalar | character vector
Description for the Simulink based state, specified as a string scalar or character vector.
Document
— Document link
""
(default) | string scalar | character vector
Document link for the Simulink based state, specified as a string scalar or character vector.
Tag
— User-defined tag
[]
(default) | any data type
User-defined tag for the Simulink based state, 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 Simulink based state 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
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 |
dialog | Open properties dialog box |
view | Display object in editing environment |
highlight | Highlight graphical object |
fitToView | Zoom in on graphical object |
Examples
Add Simulink Based State to Chart
Add a Simulink based state in the chart ch
. Set its name to
A
.
simulinkBasedState = Stateflow.SimulinkBasedState(ch);
simulinkBasedState.Name = "A";
Map Variables in Simulink Based State
Since R2023a
In a Simulink based state called Locked
, modify the mapping for the output we
.
Open the model sf_clutch.slx
.
open_system("sf_clutch.slx")
Access the Stateflow.SimulinkBasedState
object for the Simulink based state Locked.
subsystem = find(sfroot,"-isa","Stateflow.SimulinkBasedState", ... Name="Locked");
Check the mapping for Simulink based state output we
.
getMappingForSymbol(subsystem,"we").Name
ans = 'we'
Map the Simulink based state output we
to chart output wv
.
setMappingForSymbol(subsystem,"we","wv") getMappingForSymbol(subsystem,"we").Name
ans = 'wv'
Clear the mapping for Simulink based state output we
.
clearMappingForSymbol(subsystem,"we") getMappingForSymbol(subsystem,"we").Name
ans = 'we'
Version History
Introduced in R2017bR2023a: New object functions and properties
Stateflow.SimulinkBasedState
objects have new object functions and properties:
The object function
setMappingForSymbol
maps a Simulink based state symbol to a main chart symbol.The object function
clearMappingForSymbol
clears the mapping for a Simulink based state symbol.The object function
getMappingForSymbol
returns the main chart symbol that a Simulink based state symbol maps to.The object function
getReferences
returns the locations where a chart refers to the name of a Simulink based state.The object function
renameReferences
renames a Simulink based state and updates all references to the name of the Simulink based state in the chart.The object function
commentedBy
identifies the explicitly commented objects that cause a Simulink based state to be commented out.The property
IsCommented
indicates whether a Simulink based state is commented out. This property replaces the object functionisCommented
.
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
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)