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?