You can save signal values to the MATLAB workspace or to a MAT-file during simulation for later retrieval and postprocessing. Saving simulation data is also known as logging or exporting simulation data.
Saving simulation data in Dataset
format simplifies
postprocessing by providing a common format for the results of a variety of
logging techniques. Using Dataset
format stores the data
as MATLAB
timeseries
objects, which you can process with
MATLAB.
Signal logging and data stores use Dataset
format.
Output and state logging use Dataset
as the
default format.
The default save format for the To File and To Workspace
blocks is Timeseries
.
Simulink® provides tools to convert logged data to
Dataset
format.
To determine which approach to use for logging signal data, see Export Simulation Data.
Outport | Create output port for subsystem or external output |
To File | Write data to file |
To Workspace | Write data to workspace |
Export (log) simulation data as a baseline for analyzing and debugging a model.
Data Format for Logged Simulation Data
You can use many formats for logged data, including Dataset, MATLAB timeseries, arrays, and structures. Supported data formats vary between different logging techniques. However, Dataset format is available for all logging techniques.
Dataset Conversion for Logged Data
To convert a workspace variable that contains data that was logged in a format other than Dataset format to use Dataset format, use a Simulink.SimulationData.Dataset constructor.
Work with Big Data for Simulations
Log, load, and analyze big data for simulations.
Reduce the amount of data logged during a simulation.
Log Data to Persistent Storage
Store logged simulation data to persistent storage in a MAT-file.
Load big data as simulation input.
Analyze Big Data from a Simulation
Access simulation data logged to persistent storage for analysis in MATLAB.
Log Signal Data That Uses Units
Log signal data that uses units by using Dataset or Timeseries logging format for signal logging, the To File block, and the To Workspace block.
Model Configuration Parameters: Data Import/Export
Use the Data Import/Export category of model configuration parameters to specify the simulation results to log and how to format and display the logging output.
How blocks use the state information for calculating the output signal value for the current simulation step.
Save state information for logged states for each simulation step during a simulation.
Reduce the amount of data logged during a simulation.
Samples to Export for Variable-Step Solvers
Control how much output the simulation generates when your model uses a variable-step solver. Use the Output options configuration parameter.
Export Signal Data Using Signal Logging
To capture signal data from a simulation, you can use signal logging. Mark the signals that you want to log and enable signal logging for the model.
Configure a Signal for Logging
Mark the signals that you want to log simulation data for.
View the Signal Logging Configuration
View the signals that are marked for signal logging.
Enable Signal Logging for a Model
To log signals marked for signal logging, set the Signal logging configuration parameter.
Override Signal Logging Settings
For a specific simulation run, override the signal logging settings for individual signals marked for logging.
View and Access Signal Logging Data
View and access the signal logging data for a completed or paused simulation.
Convert Logged Data to Dataset Format
To convert a workspace variable that contains data that was logged in a format other than Dataset format to use Dataset format, use a Simulink.SimulationData.Dataset constructor.
Log Signals in For Each Subsystems
Use signal logging in For Each subsystems.
Configure a data store for logging so that you can view the data stored in a simulation run.