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?
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!