How to get names of input ports on simulink block?

11 次查看(过去 30 天)
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
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 CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by