0
votes

What is the best possible solution to get an underlying MATLAB Simulink Subsystem Inport/Outport Block via Port Handle?

I use the following code snippet for Outports to navigate from the Connection-Line to the Port Handle and determine the Parent/Port Number for searching it via find_system:

SrcPort = get_param(Line,'SrcportHandle'); 
SrcPortParent = get(SrcPort,'Parent');
SrcPortNumber = get(SrcPort,'PortNumber');
SrcPortBlock = find_system(SrcPortParent,'LookUnderMasks','all','FollowLinks','On','SearchDepth',1,'BlockType','Outport','Port',num2str(SrcPortNumber));

Is there a better solution to get the underlying Port Block?

1

1 Answers

1
votes

There is no straightforward way, you already found what I consider the best option. For reference, the MathWorks Support Team confirms that there is no better option.