Effacer les filtres
Effacer les filtres

Find names of ports in Subsystem connected to input ports

21 vues (au cours des 30 derniers jours)
Arunkumar Muthukumaran
Arunkumar Muthukumaran le 5 Mai 2015
Commenté : ciming zhu le 26 Avr 2023
I have some input ports connected to the port of a subsystem. I know the names of all input ports. How to find the names of ports in subsystem which are connected to inports. For example: If I consider inport A1, I should findout the name B1, which is the name of the port in system connected to A1.
Thanks.
  1 commentaire
ciming zhu
ciming zhu le 26 Avr 2023
I have the same problem as you,I wonder that did you figure out how to solve this problem?Thanks a lot!!

Connectez-vous pour commenter.

Réponses (2)

Israa Abdullah
Israa Abdullah le 17 Nov 2019
What is the answer please?

Oleksandr Pylypenko
Oleksandr Pylypenko le 4 Fév 2020
this script will sustitute name of subsystem inport with respect to connected outer inport. It will work also with only some ONE block in the middle between outer inport and subsystem.
% select subsystem
sel_subsystems = find_system(gcs,'Selected','on');
if(length(sel_subsystems)==2)
sel_subsystem = sel_subsystems(2);
else
sel_subsystem = sel_subsystems;
end
block_of_interest = get_param(cell2mat(sel_subsystem),'Handle');
% subsystem inport handle
sub_handles = find_system(block_of_interest, 'LookUnderMasks', 'on', 'FollowLinks', 'on', 'SearchDepth', 1, 'BlockType', 'Inport');
selected_pc = get_param(block_of_interest,'PortConnectivity');
SrcBlock_h = [selected_pc(:).SrcBlock];
%check if connected block is port type block: BlockType == Inport
for blk=1:length(SrcBlock_h)
connected_blocktype = get_param(SrcBlock_h(blk),'BlockType');
if (contains(connected_blocktype,'Inport'))
% Substitute name
inport_name = get_param(SrcBlock_h(blk),'Name');
set_param(sub_handles(blk),'Name',inport_name);
else
% check block connected to this one
pc_L2 = get_param(SrcBlock_h(blk),'PortConnectivity');
SrcBlock_L2_h = [pc_L2(:).SrcBlock];
if(length(SrcBlock_L2_h)>1)
disp("Connection Level 2 error. More than 1 connection!")
return;
end
inport_name = get_param(SrcBlock_L2_h(1),'Name');
set_param(sub_handles(blk),'Name',inport_name);
end
end

Catégories

En savoir plus sur Interactive Model Editing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by