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!