MATLAB: Is there a way to access the line information that connects every block in the Simulink model

get_paramparameterspropertiesset_paramsimulink

Is there a way to access the line information that connects every block in my Simulink model?

Best Answer

There is no direct way to access the line connectivity, however you can try the following:
%open simulink model vdp.mdl
open_system('vdp')
%Find all the line handles for this model
h = find_system('vdp','FindAll','On','type', 'line');
k = 15; % line 15
%You can use get_param(h(k),'objectparameters') to find all
%the properties for the kth line
%Get the block handles
hblkSrc = get_param(h(k),'SrcBlockHandle');
hblkDst = get_param(h(k),'DstBlockHandle');
%display the line name, source block and destination
%using the SPRINTF command
sprintf('LineName: %s Source Block : %s Destination Block: %s', ...
get_param(h(k),'name'),get_param(hblkDst,'Name'), ...
get_param(hblkSrc,'Name'))