Main Content

Saving and Retrieving Logged Simulation Data

Ways of saving and retrieving logged simulation data depend on the logging method. Each simulation log has two properties, savable and exportable, that indicate how the data was logged and therefore, how to save and retrieve it.

Logging MethodEnabled BySavableExportableUse

Memory

Stream data to temporary disk directory preference is off, Record data in Simulation Data Inspector option is off

1

0

MATLAB® save and load functions, Workspace Variables and MAT-Files

Temporary File on Disk

Stream data to temporary disk directory preference is on, Record data in Simulation Data Inspector option is off

0

1

simscape.logging.export and simscape.logging.import

Simulation Data Inspector

Record data in Simulation Data Inspector option is on

0

0

Simulation Data Inspector data management functions, Analyze Simulation Results

Data Logged to Memory

When you log simulation data to workspace (Stream data to temporary disk directory check box on the Simscape pane of the Preferences dialog box is off), all the data is stored in the workspace variable. You can use the regular MATLAB interface to save the workspace variable as a MAT-file and load a MAT-file into a variable. For more information, see Workspace Variables and MAT-Files.

Data Logged to Temporary File on Disk

When you stream simulation data to disk (Stream data to temporary disk directory check box on the Simscape pane of the Preferences dialog box is on), the data is stored as a simlog object in a temporary file, and the workspace variable references the simlog object. The temporary file persists as long as there is a logging variable name in the workspace that references it. The simscape.logging.export function saves the logged simulation data to an MLDATX file, other than the temporary file, for use in a later session. To load the MLDATX file containing the stored simlog object back into workspace and associate it with a workspace variable, use the simscape.logging.import function.

The following restrictions apply:

  • When streaming data to disk, you can export and import only the entire simlog object. This is different from logging data to workspace, where you can save part of the workspace variable (such as a node in the simlog tree) as a separate MAT-file.

  • simscape.logging.export function does not support cross-locale characters in file name.

Data Recorded in Simulation Data Inspector

If you select the Record data in Simulation Data Inspector check box on the Simscape pane of the Configuration Parameters dialog box for a particular model, this choice overrides the logging preference. The simlog object has both savable and exportable properties set to 0. You must use the Simulation Data Inspector data management functions to save and retrieve this data. For more information, see Analyze Simulation Results.

Related Topics