View and Access Logged Simulation Data - MATLAB & Simulink (original) (raw)
Main Content
Logged simulation data can include any combination of output, signal, time, state, and data store logging data. You can log data to a file or to the workspace. You can view logged data during simulation using the Simulation Data Inspector, or for paused or stopped simulations, by using other visualization interfaces. See Decide How to Visualize Simulation Data.
Alternatively, you can access simulation data that has been logged to the workspace programmatically, using MATLABĀ® commands.
View Logged Data Using Simulation Data Inspector
To inspect logged simulation data interactively, consider using the Simulation Data Inspector. Data logged in Dataset
format is automatically logged in the Simulation Data Inspector. To view data logged using a format other thanDataset
, open the Configuration Parameters dialog box. In theData Import/Export pane, select the Record logged workspace data in Simulation Data Inspector parameter. For more information, see View Simulation Data in Simulation Data Inspector.
Depending on the logging technique used and the format of the data, some logged data can also stream to the Simulation Data Inspector during simulation. For more information, seeView Streaming Data in the Simulation Data Inspector.
Access Logged Data Programmatically
You can access and analyze data logged to the workspace programmatically. By default, all simulation data logged to the workspace is returned as a single Simulink.SimulationOutput object in a variable with the default nameout
. The Simulink.SimulationOutput
object contains complete simulation metadata and all simulation data logged to the workspace. Each logged data type becomes a property of the Simulink.SimulationOutput
. The name of the property matches the name you specify for the logging variable. For example, when you log data using signal logging and use the default variable name logsout
, the Simulink.SimulationOutput
object has the propertylogsout
that contains the logged signal data.
This table summarizes the default property name for several common logging techniques.
Logged Data | Default Variable Name in Workspace |
---|---|
Output data | yout |
Signal logging data | logsout |
Signal data logged using a Record block | recordout |
Signal data logged using a To Workspace block | simout |
Signal data logged using a Scope block | ScopeData |
Time data | tout |
States data | xout |
Final states data | xFinal |
Data stores | dsmout |
When simulation results are returned as a singleSimulink.SimulationOutput
object, you can access logged data using a dot. For example, if output data is logged using the default name yout
, then you can use the property yout
to access logged output data.
outputData =
Simulink.SimulationData.Dataset 'yout' with 1 element
Name BlockPath
_________________ ______________________
1 [1x1 Signal] Data from Outport LoggingTechniques/Out1
- Use braces { } to access, modify, or add elements using index.
For an example of accessing signal logging data programmatically, see Visualize and Access Signal Logging Data.
See Also
Model Settings
Objects
Blocks
- Record | Outport | To Workspace | To File | Scope | Data Store Memory