Save logged simulation data in MLDATX file
simlog object, containing logged simulation
data, for future use. You can use this function only for data logged
with the Stream data to temporary disk directory preference
When you stream simulation data to disk, the data is stored as a
object in a temporary file, and the workspace logging variable references the
simlog object. The temporary file persists as long as there is a
logging variable in the workspace that references the file. This function lets you save the
simlog object to a different file, specified by the
fileName argument, in MLDATX format.
Save Logged Simulation Data Streamed to Disk
To enable streaming data to disk, on the MATLAB® Toolstrip, click Preferences. In the left pane of the Preferences dialog box, select Simscape, then select the Stream data to temporary disk directory check box.
Open the Permanent Magnet DC Motor example model, which already has data logging enabled, and run the simulation:
During the simulation, logged data is streamed to disk, to a temporary MLDATX file.
After the simulation, you see the simulation log variable
simlog_ssc_dcmotor (as specified by the Workspace
variable name model configuration parameter) in your current
simlog_ssc_dcmotor = Node with properties: id: 'ssc_dcmotor' savable: 0 exportable: 1 MRRef_Torque: [1x1 simscape.logging.Node] Load_Torque: [1x1 simscape.logging.Node] DC_Voltage: [1x1 simscape.logging.Node] DC_Motor: [1x1 simscape.logging.Node] ERef: [1x1 simscape.logging.Node] Sensing: [1x1 simscape.logging.Node] MRRef_Motor: [1x1 simscape.logging.Node]
exportable: 1 property of the
simlog_ssc_dcmotor variable indicates that this variable points to
the temporary file on disk, which contains the simulation data. The temporary file
exists as long as the variable exists in your workspace, then it is deleted.
To save the logged simulation data for future use, type:
This command creates a file under
motor_run1.mldatx, and stores the logged simulation data in this
file, in MLDATX format.
To retrieve the logged simulation data at a later time and associate
it with a workspace variable, use the
simlog — Logged simulation data
Logged simulation data, specified as a
Node object, with the
exportable property set to
1. You refer to the
simlog object by the name of the corresponding simulation log
workspace variable. You specify the name of the simulation log variable by using the
Workspace variable name parameter in the
Simscape pane of the Configuration Parameters dialog box.
fileName — File name and path
character vector | string scalar
File name and path, specified as a character vector or string scalar. The function stores the
simlog object in the specified file, in MLDATX or HDF5 format. If
you omit the file extension, the data is stored in an MLDATX file. To save the
simlog object in HDF5 format, the
character vector must include the
.h5 extension. If you specify a
file extension other that
.mldatx, you get
an error. If you do not include the path, the file resides in the current working
If the file already exists, the function overwrites it without a warning. However, if you import a node from a file, and then try to export it to the same file, a message informs you that in this case the file cannot be overwritten.
Version HistoryIntroduced in R2016a
R2020b: File format when streaming logged simulation data to disk has changed from HDF5 to MLDATX
Behavior changed in R2020b
In R2020b, the file format for streaming logged simulation data to disk has changed from
HDF5 to MLDATX. As a result, the default format for
simscape.logging.import has also changed to MLDATX. However, you can
still export and import HDF5 files:
When you use
simscape.logging.exportwithout specifying the file extension, the data is stored in an MLDATX file in the temporary directory.
Currently, you can still export data in HDF5 format, to share it with colleagues who are using older software releases. To do this, specify
.h5file extension when using
simscape.logging.export. The function stores the data in HDF5 format and issues a warning that this functionality will be removed in a future release. If you specify a file extension other that
.mldatx, you get an error.
When you import an HDF5 file from a previous release using
simscape.logging.import, the data is automatically converted to the new format, loaded into the
Nodeobject, and copied to a binary MLDATX file in the temporary directory. If there are two files with the same name and different extensions (
.mldatx), then the MLDATX file is loaded.