Main Content

get

Access node of simulation logging data tree using slash-delimited path

Since R2020b

Description

node = get(simlog, simlogPath) returns a simscape.logging.Node object associated with the specified path, simlogPath, in the simulation logging data tree, simlog. Before you call this object function, you must have the simulation log variable in your current workspace. Create the simulation log variable by simulating the model with data logging turned on, or load a previously saved variable from a file.

This object function provides an alternative method of traversing a simulation logging data tree, by using a slash-delimited path of block names instead of a dot-delimited path of node IDs. It is especially convenient if your model contains blocks with non-ASCII characters in their names, because these names are not easily translatable into node IDs. The added benefit is tab completion, which lets you specify simlogPath with little or no typing.

example

Examples

collapse all

Open the Permanent Magnet DC Motor example model, which already has data logging enabled, and run the simulation to create the simulation log variable simlog_PermanentMagnetDCMotor (as specified by the Workspace variable name model configuration parameter) in your current workspace:

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

Get the node corresponding to the Inertia block in the DC Motor subsystem:

n = get(simlog_PermanentMagnetDCMotor,'DC Motor/Inertia')
n = 

  Node with properties:

            id: 'Inertia'
       savable: 1
    exportable: 0
             t: [1×1 simscape.logging.Node]
             w: [1×1 simscape.logging.Node]
             I: [1×1 simscape.logging.Node]

n is the Node object corresponding to the Inertia block in the DC Motor subsystem.

Note that the path starts with a block name (DC Motor), not with the name of the model (PermanentMagnetDCMotor).

Instead of typing the path, you can use tab completion.

Start by typing the partial command that includes the name of the simulation log variable:

m = get(simlog_PermanentMagnetDCMotor,

and press the Tab key.

The function adds a double quote to the command line and opens a drop-down list of all the top-level blocks in the model diagram. From this drop-down list, select DC Motor/. The function adds this name to the path:

m = get(simlog_PermanentMagnetDCMotor,"DC Motor/

Press the Tab key again and select Inertia/ from the drop-down list. Close the double quotes and the parentheses, then press Return:

m = get(simlog_PermanentMagnetDCMotor,"DC Motor/Inertia/")
m = 

  Node with properties:

            id: 'Inertia'
       savable: 1
    exportable: 0
             t: [1×1 simscape.logging.Node]
             w: [1×1 simscape.logging.Node]
             I: [1×1 simscape.logging.Node]

m is also the Node object corresponding to the Inertia block in the DC Motor subsystem, equivalent to n.

Input Arguments

collapse all

Simulation log workspace variable that contains the logged model simulation data, specified as a Node object. 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.

Path to a node in a simulation logging data tree, specified as a slash-delimited path of block, port, and variable names. The path must start with a block name, not with the name of the model.

Data Types: char | string

Output Arguments

collapse all

Node in the simulation data log tree corresponding to the specified path, returned as a Node object. The Node object, which is of class simscape.logging.Node, contains logged simulation data for the specified block, port, or variable. Generates an error if the node is not found.

Version History

Introduced in R2020b