How to get names of input ports on simulink block?

7 ビュー (過去 30 日間)
Adam Truelove
Adam Truelove 2018 年 10 月 15 日
回答済み: Rajanya 2025 年 2 月 11 日 11:07
Is there a way to get the name of the input ports on a Simulink block? I don't mean the names of the signals coming into the block (which are fairly simple to get), but the names assigned to the inports themselves?

回答 (1 件)

Rajanya
Rajanya 2025 年 2 月 11 日 11:07
You can utilize the 'get_param' function on any custom Simulink block that contains Inports or Outports to obtain the handle for that block. With this handle, you can then use 'find_system' to identify all 'Inports' or 'Outports' and subsequently retrieve their names.
blockHandle=get_param(gcb,'Handle'); %set the current block appropriately
portHandle=find_system(blockHandle,'BlockType','Inport');
portNames = cellstr(get_param(portHandle, 'Name'));
For more information on 'get_param' and 'find_system', you can refer to their respective documentation pages by executing the following commands from MATLAB Command Window:
doc get_param
doc find_system
Thanks.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by