Main Content

Save Run-Time Data from Simulation

Save simulation data to MATLAB® workspace; log signals; export signal, time, output, and state data

You can save signal values to the MATLAB workspace or to an MLDATX file, MAT-file, or Excel® 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.

Blocks

OutportCreate output port for subsystem or external output
RecordLog data to the workspace, to a file, or both
To FileWrite data to file
To WorkspaceWrite data to workspace

Functions

expand all

Simulink.sdi.markSignalForStreamingTurn logging on or off for a signal
Simulink.sdi.getSignalInputProcessingModeGet setting of Input Processing signal property
Simulink.sdi.setSignalInputProcessingModeSpecify value for Input Processing signal property
Simulink.SimulationData.signalLoggingSelectorOpen Signal Logging Selector

Configure Logged Data Size Limits

Simulink.sdi.setMaxDiskUsageSpecify maximum size for data logged to disk
Simulink.sdi.getMaxDiskUsageGet configured maximum size for data logged to disk
Simulink.sdi.setRequiredFreeSpaceSpecify minimum disk space to leave free when logging data
Simulink.sdi.getRequiredFreeSpaceGet configured minimum disk space requirement for logging
Simulink.sdi.setDeleteRunsOnLowSpaceSpecify behavior when logged data size approaches configured limits
Simulink.sdi.getDeleteRunsOnLowSpaceGet configured behavior when size of logged data approaches configured limits
Simulink.sdi.setRecordDataSpecify record mode for logging
Simulink.sdi.getRecordDataCheck record mode for logging

Configure Simulation Data Inspector Archive

Simulink.sdi.setArchiveRunLimitSpecify a limit for the number of runs stored in the Simulation Data Inspector archive
Simulink.sdi.setAutoArchiveModeSpecify whether the Simulation Data Inspector automatically archives simulation runs
Simulink.sdi.getArchiveRunLimitDetermine configured run limit for Simulation Data Inspector archive
Simulink.sdi.getAutoArchiveModeDetermine if the Simulation Data Inspector is configured to automatically archive
Simulink.sdi.setStorageLocationSpecify location for logged data on disk
Simulink.sdi.getStorageLocationGet path to custom storage location for data logged to disk
Simulink.sdi.setStorageModeSpecify whether to log data to disk or memory
Simulink.sdi.getStorageModeCheck if logging is configured to log data to disk or memory
Simulink.SimulationData.createStructOfTimeseriesCreate structure of timeseries data to load as simulation input for bus
Simulink.SimulationData.forEachTimeseriesCall function on each timeseries object
Simulink.SimulationData.DatasetRef.getDatasetVariableNamesList names of Dataset variables in MAT-file
getAsDatastoreGet matlab.io.datastore.SimulationDatastore representation of element from referenced Dataset object
Simulink.ModelDataLogs.convertToDatasetConvert logging data from Simulink.ModelDataLogs format to Simulink.SimulationData.Dataset format
Simulink.SimulationData.updateDatasetFormatLoggingConvert model and its referenced models to use Dataset format for signal logging

Classes

expand all

Simulink.SimulationOutputAccess simulation results
Simulink.SimulationData.DatasetCreate Simulink.SimulationData.Dataset object
Simulink.SimulationData.SignalContainer for signal logging information
Simulink.SimulationData.DatasetRefCreate Simulink.SimulationData.DatasetRef object
matlab.io.datastore.SimulationDatastoreDatastore for inputs and outputs of Simulink models
Simulink.SimulationData.BlockPathFully specified Simulink block path
Simulink.SimulationData.StateState logging element
Simulink.SimulationData.UnitStore units for simulation data
Simulink.SimulationData.LoggingInfoSignal logging override settings
Simulink.SimulationData.ModelLoggingInfoSignal logging override settings for a model
Simulink.SimulationData.SignalLoggingInfoSignal logging override settings for signal
Simulink.SimulationMetadataAccess metadata of simulation runs

Simulink Configuration Parameters

Topics

Simulation Data

Export Simulation Data

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.

Limit the Size of Logged Data

Choose among several strategies to limit the size of logged data.

Specify Signal Values to Log

Specify which signal values to log during simulation.

Log Data to Persistent Storage

Store logged simulation data to persistent storage in a MAT-file.

Load Big Data for Simulations

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.

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.

Log Data to the Workspace and a File Using the Record Block

Use the Record block to log data to the workspace, to a file, or to both the workspace and a file.

Simulation State

State Information

How blocks use the state information for calculating the output signal value for the current simulation step.

Save State Information

Save state information for logged states for each simulation step during a simulation.

Signal Logging

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.

Data Stores

Log Data Stores

Configure a data store for logging so that you can view the data stored in a simulation run.

Featured Examples