Main Content

getSource

Navigate from node object to block that generated it

Description

block_id = getSource(node) returns the Simulink Identifier (SID) of the block that generated data in the specified simscape.logging.Node object. If the node object corresponds to a variable, returns the parent block for that variable. Before you call this object function, you must load the model. You must also 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.

example

Examples

collapse all

Open the Full-Wave Bridge Rectifier example model and run the simulation:

openExample('simscape/FullWaveBridgeRectifierExample')
sim('FullWaveBridgeRectifier');

The model has data logging enabled for all blocks, with Workspace variable name parameter set to simlog_FullWaveBridgeRectifier. Therefore, running the simulation creates the simulation log variable in your current workspace.

Print the complete logging tree for the model:

print(simlog_FullWaveBridgeRectifier)
     FullWaveBridgeRectifier
     +-AC_Voltage_Source
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-v
     +-C
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-power_dissipated
     | +-v
     | +-vc
     +-Diode_1
     | +-SimulationStatistics
     | | +-zc_1
     | |   +-crossings
     | |   +-values
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-power_dissipated
     | +-v
     +-Diode_2
     | +-SimulationStatistics
     | | +-zc_1
     | |   +-crossings
     | |   +-values
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-power_dissipated
     | +-v
     +-Diode_3
     | +-SimulationStatistics
     | | +-zc_1
     | |   +-crossings
     | |   +-values
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-power_dissipated
     | +-v
     +-Diode_4
     | +-SimulationStatistics
     | | +-zc_1
     | |   +-crossings
     | |   +-values
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-power_dissipated
     | +-v
     +-ERef_T1
     | +-V
     |   +-v
     +-ERef_T2
     | +-V
     |   +-v
     +-Ideal_Transformer
     | +-i1
     | +-i2
     | +-n1
     | | +-v
     | +-n2
     | | +-v
     | +-p1
     | | +-v
     | +-p2
     | | +-v
     | +-v1
     | +-v2
     +-Load
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-power_dissipated
     | +-v
     +-Voltage_Sensor
       +-V
       +-n
       | +-v
       +-p
         +-v

Find Simulink Identifier for the block corresponding to the Diode_1 node:

id = getSource(simlog_FullWaveBridgeRectifier.Diode_1)
id =

FullWaveBridgeRectifier:3

FullWaveBridgeRectifier:3 is the Simulink Identifier of the block corresponding to the specified node.

Based on the Simulink Identifier, get the full block path name:

blockName = getfullname(id)
blockName =

FullWaveBridgeRectifier/Diode 1

FullWaveBridgeRectifier/Diode 1 is the full path and name of the block.

Input Arguments

collapse all

Node in the simulation data log tree, specified as a simscape.logging.Node object. You specify the name of the simulation log variable by using the Workspace variable name parameter on the Simscape pane of the Configuration Parameters dialog box. To specify a node within the simulation log variable, provide the complete path to that node through the simulation data tree, starting with the top-level variable name.

Example: simlog.DC_Motor.Inertia

Output Arguments

collapse all

Simulink Identifier (SID) of the block that generated data in the specified node object. If the node object corresponds to a variable, returns the parent block for that variable.

Version History

Introduced in R2015b