How to know which block connected with outport block in a subsystem?

Illustration
DevanujDeka - 2021-09-11T13:09:00+00:00
Question: How to know which block connected with outport block in a subsystem?

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?

Expert Answer

Profile picture of Kshitij Singh 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).

Recommended Approach (Using the Subsystem Block)

This is often the easiest, especially if the Outport is directly connected outside without branching.

  1. Get the line handles from the subsystem block (replace 'myModel/mySubsystem' with your subsystem path):

    matlab
     
    lineHandles = get_param('myModel/mySubsystem', 'LineHandles');
     
     
  2. Get the destination block handles from the Outport lines:

    matlab
     
    dstHandles = get_param(lineHandles.Outport, 'DstBlockHandle');
     
     
  3. Convert to full block paths (handles are in a cell array if multiple Outports):

    matlab
     
    outsideBlockPaths = getfullname(dstHandles);
     
     
    • If there's only one Outport and one direct connection, outsideBlockPaths will be a string (e.g., 'myModel/SomeBlock').
    • If branched (one Outport line splits to multiple blocks), it will be a cell array of paths.
  4. Get any property of the outside block(s), e.g., block type:

    matlab
     
    blockType = get_param(outsideBlockPaths{1}, 'BlockType');  % For the first one
     
     

    Or all parameters:

    matlab
     
    params = get_param(outsideBlockPaths{1}, 'ObjectParameters');
     
     

Alternative Approach (Starting from the Outport Block Inside the Subsystem)

If you know the specific Outport block path (e.g., 'myModel/mySubsystem/Out1'):

  1. Get port handles:
    matlab
     
    portHandles = get_param('myModel/mySubsystem/Out1', 'PortHandles');
     
     
  2. Get the line handle from the Outport:
    matlab
     
    lineHandle = get_param(portHandles.Outport(1), 'Line');  % Usually one Outport
     
     
  3. Get destination block handle(s):
    matlab
     
    dstHandles = get_param(lineHandle, 'DstBlockHandle');
     
     
  4. Then proceed as above with getfullname(dstHandles) and get_param.

This works even if the line branches outside the subsystem.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!