Get signal lines in a linked library in Simulink

7 ビュー (過去 30 日間)
Prabhakar Vallury
Prabhakar Vallury 2023 年 1 月 26 日
編集済み: Fangjun Jiang 2023 年 1 月 30 日
[Simulink version 2019b]
I have a Simulink model called 'main.slx' with several linked library blocks (all resolved). One of these ilinked libraries is called 'link1'. I need to get all the signal lines inside 'link1'
Scenario 1:
I open link1.slx directly in Simulink and click on it. I get all the signals using find_system(gcb, 'FindAll', 'on', 'type', 'line'). This works well.
Scenario 2:
I open main.slx in Simulink and click on the link1 block. This time the same find_system command returns empty. I go deeper into link1 and try again, but still no result.
Is there a direct way to achieve this result? Do I need to get the pathname for link1, open it locally and then run the find_system command? That would be very time-consuming. Hopefully there's a better/faster way? TIA.

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2023 年 1 月 26 日
Not sure if "link1.slx" is a model/subsystem or a library, which results in a subsystem reference or a library link.
In any case, it sounds like you need to add one of these options
'FollowLinks','On'
'LookInsideSubsystemReference','On'
  6 件のコメント
Prabhakar Vallury
Prabhakar Vallury 2023 年 1 月 30 日
That is correct but I was hoping to programmatically get all line handles directly by querying main.slx with find_system. That doesn't work, so I have to loop through all the linked library blocks that exist within main.slx and get the line handles for each one. In this, I have to ignore annotation blocks, etc. as well. Makes it a little more convoluted, but that's okay. Would've been nice to get all handles from the top-level query, that's all I'm saying.
Thanks for the guidance.
Fangjun Jiang
Fangjun Jiang 2023 年 1 月 30 日
編集済み: Fangjun Jiang 2023 年 1 月 30 日
I don't understand the problem. I dragged a "PID Controller" library block (it is a masked block) to a new empty model "untitled" and ran below. It found 160 line handles. All are inside the library block.
lines=find_system('untitled','FindAll','On', 'FollowLinks','On','LookUnderMasks','All','type', 'line')

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

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by