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
Record, XY GraphLog data to the workspace, to a file, or both
To FileWrite data to file
To WorkspaceLog data to workspace from Simulink model

Tools

Instrumentation PropertiesView and edit logging and visualization properties for logged signal
Signal PropertiesView and edit signal properties
Simulation Data InspectorInspect and compare data and simulation results to validate and iterate model designs

Functions

expand all

Simulink.sdi.markSignalForStreamingTurn logging on or off for a signal
Simulink.sdi.getSignalInputProcessingModeGet value 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 number of runs to retain in Simulation Data Inspector archive
Simulink.sdi.setAutoArchiveModeSpecify how Simulation Data Inspector manages simulation runs
Simulink.sdi.getArchiveRunLimitGet limit for number of runs to retain in Simulation Data Inspector archive
Simulink.sdi.getAutoArchiveModeGet Simulation Data Inspector run management mode
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
extractTimetableExtract data from Simulink.SimulationData.Dataset or Simulink.SimulationData.Signal objects into timetables
getAsDatastoreGet matlab.io.datastore.SimulationDatastore representation of element from referenced Dataset object
removeElementRemove element from Simulink.SimulationData.Dataset object
Simulink.SimulationData.createStructOfTimeseriesCreate structure of timeseries data to load as simulation input for bus
Simulink.SimulationData.forEachTimeseriesApply function to data contained in set of timeseries objects
Simulink.SimulationData.DatasetRef.getDatasetVariableNamesList names of variables in MAT file that contain Simulink.SimulationData.Dataset objects

Objects

expand all

Simulink.SimulationOutputAccess simulation outputs and metadata
Simulink.SimulationMetadataAccess metadata of simulation runs
Simulink.SimulationData.DatasetAccess logged simulation data or group simulation input data
Simulink.SimulationData.SignalContainer for signal logging information
Simulink.SimulationData.StateState logging element
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.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

Topics

Simulation Data

Simulation State

Signal Logging

Data Stores

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