Documentation

我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

Save Runtime 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 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.

Blocks

Outport Create output port for subsystem or external output
To File Write data to file
To Workspace Write data to workspace

Functions

Simulink.ModelDataLogs.convertToDataset Convert logging data from Simulink.ModelDataLogs format to Simulink.SimulationData.Dataset format
Simulink.SimulationData.signalLoggingSelector Open Signal Logging Selector
Simulink.SimulationData.updateDatasetFormatLogging Convert model and its referenced models to use Dataset format for signal logging
unpack Extract signal logging objects from signal logs and write them into MATLAB workspace
Simulink.SimulationData.createStructOfTimeseries Create a structure with MATLAB timeseries object leaf nodes
Simulink.SimulationData.forEachTimeseries Call function on each timeseries object
Simulink.SimulationData.Unit.setName Specify name of logging data units
Simulink.SimulationData.DatasetRef.getDatasetVariableNames List names of Dataset variables in MAT-file
who List names of top-level data logging objects in Simulink ModelDataLogs data log
whos List names and types of top-level data logging objects in Simulink ModelDataLogs data log

Classes

Simulink.SimulationData.Dataset Create Simulink.SimulationData.Dataset object
Simulink.SimulationData.DatasetRef Create Simulink.SimulationData.DatasetRef object
Simulink.SimulationData.BlockPath Fully specified Simulink block path
Simulink.SimulationData.Signal Container for signal logging information
Simulink.SimulationData.State State logging element
Simulink.SimulationData.Unit Store units for simulation data
Simulink.SimulationOutput Access object values of simulation results
Simulink.SimulationData.LoggingInfo Signal logging override settings
Simulink.SimulationData.ModelLoggingInfo Signal logging override settings for a model
Simulink.SimulationData.SignalLoggingInfo Signal logging override settings for signal
Simulink.SimulationMetadata Access metadata of simulation runs

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.

Limit Amount of Exported Data

Reduce the amount of data logged during a simulation.

Log Data Using Persistent Storage

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

Access Logged Data from Persistent Storage

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.

Simulation State

State Information

Some blocks maintain state information that they use during simulation.

Save State Information

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

MATLAB Workspace

Limit Amount of Exported Data

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.

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.

Access Signal Logging Data

View 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.


Was this topic helpful?