Main Content

View and Access Logged Simulation Data

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 than Dataset, open the Configuration Parameters dialog box. In the Data 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, see View 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 name out. 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 property logsout that contains the logged signal data.

This table summarizes the default property name for several common logging techniques.

Logged DataDefault Variable Name in Workspace
Output datayout
Signal logging datalogsout
Signal data logged using a Record blockrecordout
Signal data logged using a To Workspace blocksimout
Signal data logged using a Scope blockScopeData
Time datatout
States dataxout
Final states dataxFinal
Data storesdsmout

When simulation results are returned as a single Simulink.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 = out.yout
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



Related Topics