| Contents | Index |
| On this page… |
|---|
Approaches for Exporting Signal Data Enabling Simulation Data Export Viewing Logged Simulation Data With the Simulation Data Inspector |
Simulation data can include any combination of signal, time, output, state, and data store logging data.
Exporting simulation data involves saving signal values to the MATLAB workspace during simulation for later retrieval and postprocessing. Exporting data is also known as "data logging" or "saving simulation data."
You can also import the exported data to use as input for simulating a model.
Exporting simulation data very often involves exporting signal data. You can use a variety of approaches for exporting signal data.
| Export Approach | Usage | Documentation |
|---|---|---|
Connect a signal to a Scope block or viewer. | If you want to use a Scope block for viewing results during simulation, consider using it to export data. Document in the diagram the workspace variables used to store signal data. Save output at a sample rate other than the base sample rate. Scopes store data and can be memory intensive. | |
Connect a signal to a To File block. | Consider using a To File block for exporting large amounts of data. Document in the diagram the workspace variables used to store signal data. Save output at a sample rate other than the base sample rate. Use the MAT-file only after the simulation has completed. | |
Connect a signal to a To Workspace block. | Document in the diagram the workspace variables used to store signal data. Save output at a sample rate other than the base sample rate. | |
Connect a signal to a root-level Outport block. | Consider using for logging data in a top-level model, if the model already includes an Outport block. | |
Set the signal logging properties for a signal. | Eliminate the need to add blocks. Log signals based on individual signal rates. Data is available only when simulation is paused or completed. | |
Configure Simulink to export time, state, and output data. | Capture information about the simulation run as a whole. Outputs and states are logged at the base sample rate of the model. | Selecting the Data Format for Exported Simulation Data Specifying the Amount of Exported Data Specifying Which Samples to Export for Models with Variable-Step Solvers |
Log a data store. | Share data throughout a model hierarchy, capturing the order of all data store writes. | Logging Data Stores |
Use the sim command to log simulation data programmatically. | Export to one data object the time, states, and signals simulation data. Select the Return as single object parameter when simulating the model using the sim command inside a function or a parfor loop. | sim |
To export the states and root-level outputs of a model to the MATLAB base workspace during simulation of the model, use one of these interfaces:
Configuration Parameters > Data Import/Export pane (for details, see Data Import/Export Pane)
sim command
In both approaches, you specify:
The kinds of simulation data that you want to export:
Signal logging
Time
Output
State or final state
Data store
Each kind of simulation data export has an associated default variable. You can specify your own variables for the exported data.
The characteristics of the logged data, including:
To inspect exported simulation data interactively, consider using the Simulation Data Inspector tool.
The Simulation Data Inspector has some limitations on the kinds of logged data that it displays. See Limitations of the Simulation Data Inspector Tool.
![]() | Using Simulation Data | Selecting the Data Format for Exported Simulation Data | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |