How to know which inport-block belong to which From-Block ?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi everyone,
This is an exemple of my question. Imagine that i have a lot of subsystems and in the main-system or in the subsystem itself there are too many of From-Blocks.
my question is: how to detect the the selected signale in the subsytem belong to which From-Block. In another way which inport-Block belong to which From-Block
This will work only if the Inport-Block connected in sorted way with From-Block
for exemple: [A]-Block will be detected as From, [B]-Block will be detected as From1 and Inport-Block will be detected as " 1 " , if i run my code it will work fun.
but in case that [A]-Block will be detected with From10 or another number. so how can i know programmatically that selected signal belong to which From-Block
Hier is my try:
% Select Signal data from the Simulink Model
selectObj = find_system(gcs,'findall','on','selected','on','parent',gcs); % get the selected object
parent_handle = get_param(selectObj,'SrcBlockHandle'); % get parent handle (in this case Inport-Block)
block_type = get_param(parent_handle,'BlockType'); % get the block Type
parent_path = get_param(parent_handle,'Parent'); % get the path of the parent (in this case subsystem)
parent_path=strsplit(parent_path,'/')
parent_path(end)=[];
parent_path = strjoin(parent_path,'/') % get the path of parent parent system (in this case main system)
Blocks_From = find_system(parent_path,'SearchDepth',1,'BlockType','From') % find all existed From-Blocks
port_nr = str2num(get_param(parent_handle,'Port')) % get the number of Inport-Block
signal_name = get_param(Blocks_From{port_nr,1},'GotoTag') % get the name of the from-Block
I hope someone can help
thank you in advance
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Schedule Model Components についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!