Main Content

simscape.logging.export

Save logged simulation data in MLDATX file

Description

simscape.logging.export(simlog,fileName) saves the 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 turned on.

When you stream simulation data to disk, the data is stored as a simlog 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 permanent file, specified by the fileName argument, in MLDATX format.

example

Examples

collapse all

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:

openExample('simscape/PermanentMagnetDCMotorExample')
sim('PermanentMagnetDCMotor');

During the simulation, logged data is streamed to disk, to a temporary file. After the simulation, you see the simulation log variable simlog_PermanentMagnetDCMotor (as specified by the Workspace variable name model configuration parameter) in your current workspace:

simlog_PermanentMagnetDCMotor
simlog_PermanentMagnetDCMotor = 

  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]

The exportable: 1 property of the simlog_PermanentMagnetDCMotor 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:

simscape.logging.export(simlog_PermanentMagnetDCMotor,'C:\Work\motor_run1');

This command creates a file under C:\Work, named 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 simscape.logging.import function.

Input Arguments

collapse all

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.

File name and path, specified as a character vector or string scalar. The function stores the simlog object in the specified file, in MLDATX format. You can omit the file extension. If you do not include the path, the file resides in the current working directory.

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.

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

Data Types: char | string

Version History

Introduced in R2016a

expand all