Main Content

Save Run-Time Data from Simulation

Save simulation data such as output, signal, time, state, and data store logging data

You can save simulation data to the MATLAB® workspace or to a file, including an MLDATX file, MAT file, or Excel® file, during simulation for later retrieval and postprocessing. Simulation data can include any combination of output, signal, time, state, and data store logging 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 or timetable objects, which you can process with MATLAB.

To determine which approach to use for logging data, see Save Simulation Data.

Blocks

OutportCreate output port for subsystem or external output
RecordLog data to the workspace, to a file, or both (Since R2021a)
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
Simulink Signal Logging SelectorView signal logging configuration and override signal logging settings

Functions

expand all

Simulink.sdi.markSignalForStreamingTurn logging on or off for signal
Simulink.sdi.getSignalInputProcessingModeGet value of Input Processing signal property (Since R2020a)
Simulink.sdi.setSignalInputProcessingModeSpecify value for Input Processing signal property (Since R2020a)
Simulink.SimulationData.ModelLoggingInfo.createFromModelCreate Simulink.SimulationData.ModelLoggingInfo object for top model with override settings for each logged signal in model
findSignalFind index of signals in Signals property vector
setLogAsSpecifiedInModelSet logging mode for top model or top-level Model block
getLogAsSpecifiedInModelDetermine whether model logs as specified in model or uses override settings
verifySignalAndModelPathsVerify paths in Simulink.SimulationData.ModelLoggingInfo object

Configure Logged Data Size Limits

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

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 (Since R2021a)
Simulink.sdi.getStorageLocationGet path to custom storage location for data logged to disk (Since R2021a)
Simulink.sdi.setStorageModeSpecify whether to log data to disk or memory (Since R2021a)
Simulink.sdi.getStorageModeCheck if logging is configured to log data to disk or memory (Since R2021a)
extractTimetableExtract data from Simulink.SimulationData.Dataset or Simulink.SimulationData.Signal objects into timetables (Since R2021b)
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.StateContainer for state logging information
Simulink.SimulationData.DatasetRefCreate Simulink.SimulationData.DatasetRef object
matlab.io.datastore.SimulationDatastoreDatastore for inputs and outputs of Simulink models
Simulink.SimulationData.BlockPathFully specified block path
Simulink.SimulationData.UnitContainer for units for simulation data
Simulink.SimulationData.LoggingInfoSignal logging override settings
Simulink.SimulationData.ModelLoggingInfoSignal logging override settings for model
Simulink.SimulationData.SignalLoggingInfoSignal logging override settings for signal

Model Settings

expand all

TimeOption to log time values for simulation
OutputOption to log data for top-level output ports
StatesOption to log block state values during simulation
Signal loggingOption to log data for signals marked for logging in model
Data storesOption to log data for Data Store Memory blocks
Final statesOption to log final state values
Save final operating pointOption to save complete model operating point when simulation is paused or stopped
Single simulation outputOption to return simulation results as single Simulink.SimulationOutput object
FormatFormat for logged states, output, and final states data
Log Dataset data to fileOption to log data that uses Dataset format to MAT file
Record logged workspace data in Simulation Data InspectorOption to send data logged in format other than Dataset to Data Inspector at end of simulation
DecimationOption to apply decimation factor for logged output, state, and time data
Limit data points to lastOption to log only last n data points for outputs, states, and time
Logging intervalsOption to specify time intervals in which to log simulation data
Output optionsOptions to produce output values at specified times in variable-step simulation
Output timesOption to specify times for which variable-step simulation produces output values
Refine factorOption to produce additional output values between simulation time steps

Topics

Simulation Data

Signal Logging

Big Data

Simulation State

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