Main Content

simscape.logging.import

Create simulation log variable to access data in MLDATX file

Description

var = simscape.logging.import(fileName) creates a workspace variable var, of type simscape.logging.Node, which references the simlog object in the specified MLDATX 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 MLDATX 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.

example

Examples

collapse all

This example shows how you can view and analyze logged simulation data, previously saved in an MLDATX 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.mldatx.

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')
run1 = 

  Node with properties:

              id: 'PermanentMagnetDCMotor'
         savable: 0
      exportable: 1
        DC_Motor: [1×1 simscape.logging.Node]
     MRRef_Motor: [1×1 simscape.logging.Node]
            ERef: [1×1 simscape.logging.Node]
     Load_Torque: [1×1 simscape.logging.Node]
      Step_Input: [1×1 simscape.logging.Node]
      DC_Voltage: [1×1 simscape.logging.Node]
    MRRef_Torque: [1×1 simscape.logging.Node]
         Sensing: [1×1 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_PermanentMagnetDCMotor, which was created as a result of simulating the PermanentMagnetDCMotor model and logging data to disk.

Explore the simulation data:

sscexplore(run1)

A new Simscape™ Results Explorer window opens. It contains logged simulation data, previously saved to disk. The root node, PermanentMagnetDCMotor, 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 or string scalar. The file must be in MLDATX or HDF5 format and contain logged simulation data, specified as a Node object. If you omit the extension, and there are two files with the same name and different extensions (.h5 and .mldatx), then the MLDATX file is loaded. If you specify an extension other than .mldatx or .h5, or try to import an MLDATX or HDF5 file that contains some other type of data, you get an error message.

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

Data Types: char | string

Version History

Introduced in R2016a

expand all