フィルターのクリア

Find names of ports in Subsystem connected to input ports

18 ビュー (過去 30 日間)
Arunkumar Muthukumaran
Arunkumar Muthukumaran 2015 年 5 月 5 日
コメント済み: ciming zhu 2023 年 4 月 26 日
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 件のコメント
ciming zhu
ciming zhu 2023 年 4 月 26 日
I have the same problem as you,I wonder that did you figure out how to solve this problem?Thanks a lot!!

サインインしてコメントする。

回答 (2 件)

Israa Abdullah
Israa Abdullah 2019 年 11 月 17 日
What is the answer please?

Oleksandr Pylypenko
Oleksandr Pylypenko 2020 年 2 月 4 日
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

カテゴリ

Help Center および File ExchangeInteractive Model Editing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by