MATLAB: Any way to figure out what your blocks are connected to in a model

find_systemmodelsimulink

inPorts = find_system(modelName,'SearchDepth',2,'BlockType','Inport');
outPorts = find_system(modelName,'SearchDepth',2,'BlockType','Outport');
I use that to get the Inport and Outport blocks in my model, but is there any way to see what they're connected to/from. I want to find out what's connected to my Outport block. I didn't know if I could trace it through the line that's connected to it to a Sum/Add block, or any other type of block.

Best Answer

Get the block's port handles using:
ph = get_param(gcb, 'PortHandles')
Examine ph.Inport and ph.Outport to get the handles to the block(s) connected at the input/output.