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 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 of the Simulink based state, specified as a string scalar or character vector.
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.
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.
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
.
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 and size of the Simulink based state, specified as a four-element numeric vector of the
form [left top width height]
.
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
).
Whether to display a preview of the Simulink based state 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 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
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.
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
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.
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
.
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
.
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
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;
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 Configure Signals as Test Points (Simulink).
Debugging
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
This property is read-only.
Chart that contains the Simulink based state, specified as a Stateflow.Chart
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.
This property is read-only.
Machine that contains the Simulink based state, specified as a Stateflow.Machine
object.
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 for the Simulink based state, specified as a string scalar or character vector.
Document link for the Simulink based state, specified as a string scalar or character vector.
User-defined tag for the Simulink based state, 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 Simulink based state from other objects in its parent chart.
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 a Simulink based state in the chart ch
. Set its name to
A
.
simulinkBasedState = Stateflow.SimulinkBasedState(ch);
simulinkBasedState.Name = "A";
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 R2017bStateflow.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
.
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)