Main Content

get

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

Description

example

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.

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_ssc_dcmotor (as specified by the Workspace variable name model configuration parameter) in your current workspace:

ssc_dcmotor
sim('ssc_dcmotor');

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

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

  Node with properties:

    id: 'Inertia'
     w: [1x1 simscape.logging.Node]
     t: [1x1 simscape.logging.Node]
     I: [1x1 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 (ssc_dcmotor).

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_ssc_dcmotor,

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_ssc_dcmotor,"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_ssc_dcmotor,"DC Motor/Inertia/")
m = 

  Node with properties:

    id: 'Inertia'
     w: [1x1 simscape.logging.Node]
     t: [1x1 simscape.logging.Node]
     I: [1x1 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.

Introduced in R2020b