Create simulation log variable to access data in HDF5 file


var = simscape.logging.import(fileName)



var = simscape.logging.import(fileName) creates a workspace variable var, of type simscape.logging.Node, which references the simlog object in the specified HDF5 file.

You can use this function to view and analyze simulation data that was logged with the Stream data to temporary disk directory preference turned on.

When you stream simulation data to disk, you can save the simlog object as an HDF5 file by using the simscape.logging.export function. The simscape.logging.import function lets you retrieve that data at a later time, for example, when the model is not in memory. The function associates data in the file with the workspace variable var, which you can use to access the logged simulation data. If you do not assign a variable name when calling the function, then the workspace variable name is ans.


collapse all

This example shows how you can view and analyze logged simulation data, previously saved in an HDF5 file. It builds up on the simscape.logging.export example, which shows how to save logged simulation data, streamed to disk, in a file named C:\Work\motor_run1.h5.

To retrieve that data at a later time, even when the model is not in memory, type:

run1 = simscape.logging.import('C:\Work\motor_run1.h5')
run1 = 

  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]

Variable run1, of type Node, appears in your current workspace. Its properties are identical to the properties of the simulation log variable simlog_ssc_dcmotor, which was created as a result of simulating the ssc_dcmotor model and logging data to disk.

Explore the simulation data:


A new Simscape™ Results Explorer window opens. It contains logged simulation data, previously saved to disk. The root node, ssc_dcmotor, is selected in the left pane by default. As you expand and select nodes in the left pane, the corresponding plots appear in the right pane.

Input Arguments

collapse all

File name and path, specified as a character vector, including the .h5 extension. The file must be in HDF5 format and contain logged simulation data, specified as a Node object. If you omit the extension, or try to import an HDF5 that contains some other type of data, you get an error message.

Example: 'C:\Work\motor_run1.h5'

Data Types: char

Introduced in R2016a

Was this topic helpful?