Main Content

simscape.logging.getSimulationLog

Identify latest Simscape simulation log for a model

Since R2024a

Description

example

node = simscape.logging.getSimulationLog(model) returns a simscape.logging.Node object that contains the latest Simscape™ simulation log for the specified model. Before you call this function, you must load the model. You must also have the simulation log variable in your current workspace.

This function is helpful when you work with several models within a session and have multiple simulation log variables in your workspace.

Examples

collapse all

Open the Permanent Magnet DC Motor example model, which already has data logging enabled, and run the simulation:

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

In your current workspace, right-click the simulation log variable simlog_PermanentMagnetDCMotor and rename it to simlog_motor.

Open the DC Motor subsystem, double-click the Inertia block, and modify the Inertia parameter value.

Rerun the simulation and rename the simulation log variable simlog_PermanentMagnetDCMotor to simlog_inertia.

You can repeat these steps, by modifying parameters of other blocks, rerunning the simulation, and renaming the workspace variables, until you have several variables of type Node with different names in your workspace.

Find the latest simulation log:

last_simlog = simscape.logging.getSimulationLog('PermanentMagnetDCMotor')
last_simlog = 

  Node with properties:

              id: 'PermanentMagnetDCMotor'
         savable: 1
      exportable: 0
    MRRef_Torque: [1×1 simscape.logging.Node]
      DC_Voltage: [1×1 simscape.logging.Node]
      Step_Input: [1×1 simscape.logging.Node]
        DC_Motor: [1×1 simscape.logging.Node]
     MRRef_Motor: [1×1 simscape.logging.Node]
     Load_Torque: [1×1 simscape.logging.Node]
            ERef: [1×1 simscape.logging.Node]
         Sensing: [1×1 simscape.logging.Node]

last_simlog is a Node object containing the latest simulation data log for the model.

If you use single simulation output, the function extracts the logged simulation data from the SimulationOutput object and returns it as a Node object.

Input Arguments

collapse all

Model name or model handle.

Data Types: double | char | string

Output Arguments

collapse all

Latest simulation data log object for the specified model, returned as a Node object. The Node object, which is of class simscape.logging.Node, contains the latest logged simulation data for the specified model. Returns empty [] if simulation data log for the model is not found (for example, if you clear the corresponding workspace variables).

Version History

Introduced in R2024a