Save logged simulation data in HDF5 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
simlog object in a temporary file, and the
workspace logging variable references the
The temporary file persists as long as there is a logging variable
in the workspace that references the file. This function lets you
simlog object to a different file, specified
fileName argument, in HDF5 format.
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 HDF5 file. After the simulation, you see the simulation
simlog_ssc_dcmotor (as specified by
the Workspace variable name model configuration
parameter) in your current workspace:
simlog_ssc_dcmotor = Node with properties: id: 'ssc_dcmotor' loggingMode: 'disk' 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]
loggingMode: 'disk' property of the
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.h5, and stores the logged simulation
data in this file, in HDF5 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
loggingMode property set to
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
File name and path, specified as a character vector. The function stores the
simlog object in the specified file, in HDF5 format. The
fileName character vector must include the
extension. 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.