Tracing signals in script

22 ビュー (過去 30 日間)
Christopher Lotysz
Christopher Lotysz 2018 年 5 月 22 日
移動済み: Fangjun Jiang 2024 年 5 月 16 日
I am trying to "trace" signals through a model, from the outports back to the inports. My script will go into a subsystem in the model, however, when it gets to the inports in that subsystem, I do not know how to find the corresponding signal/source block from the level above. Can anyone provide some help on how to do this? To trace into the subsystem, I am using:
subhandle = find_system(handle, 'LookUnderMasks', 'all', 'FollowLinks', 'on', 'SearchDepth', 1, 'BlockType', 'Outport');
Perhaps there is something similar to use to get back up a level?
I am also having trouble finding a matching GoTo block when I get to a From block, so any help would be appreciated. Thanks

回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2018 年 5 月 22 日
編集済み: Fangjun Jiang 2018 年 5 月 23 日
To find out the source block that is connected to the Inport block in F14
f14;
InportBlock='f14/Controller/alpha (rad)';
PortNumber=str2double(get_param(InportBlock,'Port'));
Parent=get_param(InportBlock,'Parent');
PortCon=get_param(Parent,'PortConnectivity');
SrcBlock=getfullname(PortCon(PortNumber).SrcBlock)
  8 件のコメント
Christopher Lotysz
Christopher Lotysz 2018 年 6 月 7 日
移動済み: Fangjun Jiang 2024 年 5 月 16 日
Is the F14 model a fictional one, or is there a model I can view somewhere to generate an example? Thanks
Fangjun Jiang
Fangjun Jiang 2018 年 6 月 7 日
移動済み: Fangjun Jiang 2024 年 5 月 16 日
f14 is an example model in Simulink

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


omar elkawokgy
omar elkawokgy 2024 年 5 月 16 日
I suggest you use line instead as so:
%getting root level signals
All_Lines = find_system('ModelName','FindAll','on', 'SearchDepth',1, 'type', 'line');
for i = 1 : length(All_Lines)
outportLineList = get_param(All_Lines(i), 'TraceSourceOutputports');
.
.
%similarly
inportLineList = get_param(All_Lines(i), 'TraceDestinationInputports');
What it does it memics the hilite to source option we have in GUI but it gets you list of objects to play with.

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by