Stateflow.SimulationData.State
State activity during simulation
Description
Use Stateflow.SimulationData.State
to log the activity of a state
during simulation.
Creation
In the Stateflow® Editor, select a state.
In the Simulation tab, in Prepare, select Log Self Activity. Alternatively, in the Property Inspector,under Logging, select the Log self activity check box.
Properties
Name
— Logging name of state
character array
Logging name of the state, specified as a character array. By default, the logging
name for a state is the hierarchical name using a period (.
) to
separate each level in the hierarchy of states. To assign a shorter name to the state,
in the Property Inspector, set Logging Name to
Custom
and enter a custom logging name.
Data Types: char
BlockPath
— Block path for source block
Simulink.SimulationData.BlockPath
Block path for the source block, specified as a Simulink.SimulationData.BlockPath
(Simulink) object.
Data Types: Simulink.SimulationData.BlockPath
Values
— State activity
timeseries
State activity, specified as a timeseries
object. Data values represent whether the state is active
(1
) or not active (0
). Time values correspond to
simulation time.
Data Types: timeseries
Object Functions
plot (Simulink) | Plot data in Simulation Data Inspector |
Examples
Access Logged State Activity
Open the
sf_semantics_hotel_checkin
model.openExample("sf_semantics_hotel_checkin")
For more information about this example, see How Stateflow Objects Interact During Execution.
Open the
Hotel
chart.Open the Symbols pane. In the Simulation tab, in Prepare, click Symbols Pane.
Configure the
Dining_area
state for logging.In the Stateflow Editor, select the
Dining_area
state.In the Simulation tab, under Prepare, select Log Self Activity.
In the Property Inspector, under Logging, select the Log self activity check box.
By default, the logging name for this state is the hierarchical signal name
Check_in.Checked_in.Executive_suite.Dining_area
. To assign a shorter name to the state, set Logging Name toCustom
and enterDining Room
.
Return to the Simulink® model.
Simulate the model. After starting the simulation, check into the hotel by toggling the first switch twice and order room service by toggling the second switch multiple times. During simulation, Stateflow saves logged data in a
Simulink.SimulationData.Dataset
(Simulink) signal logging object. The default name of the signal logging object islogsout
. For more information, see Save Signal Data Using Signal Logging (Simulink).Stop the simulation.
To access the signal logging object, at the MATLAB® command prompt, enter:
logsout
logsout = Simulink.SimulationData.Dataset 'logsout' with 1 element Name BlockPath ___________ ________________________________ 1 [1x1 State] Dining Room sf_semantics_hotel_checkin/Hotel
To access logged elements, use the
get
(Simulink) method.diningLog = logsout.get("Dining Room")
diningLog = Stateflow.SimulationData.State Package: Stateflow.SimulationData Properties: Name: 'Dining Room' BlockPath: [1×1 Simulink.SimulationData.BlockPath] Values: [1×1 timeseries]
To access the logged data and time of each logged element, use the
Values.Data
andValues.Time
properties. For example, arrange logged data in tabular form by using thetable
function.T = table(diningLog.Values.Time,diningLog.Values.Data); T.Properties.VariableNames = ["Time" "Data"]
T = 6×2 table Time Data __________ ____ 0 0 1.8607e+06 1 1.9653e+06 0 1.9653e+06 1 1.9653e+06 0 2.2912e+06 1
Version History
Introduced in R2017b
See Also
Stateflow.SimulationData.Data
| Simulink.SimulationData.BlockPath
(Simulink) | timeseries
| plot
(Simulink)
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 (한국어)