Skip to Main Content Skip to Search
Product Documentation

Exporting Simulation Data

Simulation Data

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.

Approaches for Exporting Signal Data

Exporting simulation data very often involves exporting signal data. You can use a variety of approaches for exporting signal data.

Export ApproachUsage 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.

Scope

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.

To File

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.

To Workspace

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.

Outport

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.

Exporting Signal Data Using Signal Logging

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

Enabling Simulation Data Export

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:

In both approaches, you specify:

Viewing Logged Simulation Data With the Simulation Data Inspector

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.

  


Related Products & Applications

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