Main Content

getSource

Navigate from node object to block that generated it

Description

example

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.

Examples

collapse all

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

ssc_bridge_rectifier
sim('ssc_bridge_rectifier');

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

Print the complete logging tree for the model:

print(simlog_ssc_bridge_rectifier)
     ssc_bridge_rectifier
     +-AC_Voltage_Source
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-v
     +-C
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-v
     | +-vc
     +-Diode_1
     | +-SimulationStatistics
     | | +-zc_1
     | |   +-crossings
     | |   +-values
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-v
     +-Diode_2
     | +-SimulationStatistics
     | | +-zc_1
     | |   +-crossings
     | |   +-values
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-v
     +-Diode_3
     | +-SimulationStatistics
     | | +-zc_1
     | |   +-crossings
     | |   +-values
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-v
     +-Diode_4
     | +-SimulationStatistics
     | | +-zc_1
     | |   +-crossings
     | |   +-values
     | +-i
     | +-n
     | | +-v
     | +-p
     | | +-v
     | +-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
     | +-v
     +-Voltage_Sensor
       +-V
       +-i1
       +-n
       | +-v
       +-p
       | +-v
       +-v1

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

id = getSource(simlog_ssc_bridge_rectifier.Diode_1)
id =

ssc_bridge_rectifier:3

ssc_bridge_rectifier: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 =

ssc_bridge_rectifier/Diode 1

ssc_bridge_rectifier/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.

Introduced in R2015b