Hi all, I have outport block in a subsystem. In outside subsystem, there is block connect with this outport block. I want to get property of that outside block by command line. Do any know?
Kshitij Singh answered .
2025-12-15
Yes, you can get the properties of the block connected outside the subsystem to a specific Outport block using MATLAB commands (via get_param and related functions).
This is often the easiest, especially if the Outport is directly connected outside without branching.
Get the line handles from the subsystem block (replace 'myModel/mySubsystem' with your subsystem path):
lineHandles = get_param('myModel/mySubsystem', 'LineHandles');
Get the destination block handles from the Outport lines:
dstHandles = get_param(lineHandles.Outport, 'DstBlockHandle');
Convert to full block paths (handles are in a cell array if multiple Outports):
outsideBlockPaths = getfullname(dstHandles);
Get any property of the outside block(s), e.g., block type:
blockType = get_param(outsideBlockPaths{1}, 'BlockType'); % For the first one
Or all parameters:
params = get_param(outsideBlockPaths{1}, 'ObjectParameters');
If you know the specific Outport block path (e.g., 'myModel/mySubsystem/Out1'):
portHandles = get_param('myModel/mySubsystem/Out1', 'PortHandles');
lineHandle = get_param(portHandles.Outport(1), 'Line'); % Usually one Outport
dstHandles = get_param(lineHandle, 'DstBlockHandle');
This works even if the line branches outside the subsystem.