- Right-click on your subsystem and navigate to Mask > Create Mask
- In the "Icon" tab, the changes you make will be reflected on the subsystem mask.
- "port_label" is the function with which you can dynamically set the port labels - https://www.mathworks.com/help/simulink/slref/port_label.html.
- "color" is the function with which you can set the colour of the objects being rendered on the mask - https://www.mathworks.com/help/simulink/slref/color.html
How can I create a dynamic output port name that updates based on an action and change output text color using system object?
3 次查看(过去 30 天)
显示 更早的评论
Looking at the image below, how can I turn the output port name to red instead of the default black color using system object? How can I update the port name to what the user has selected? For example, instead of 'NC', if the user select 3, I want to change the output port name to I3 with the color black. Thanks.

2 个评论
Raghava S N
2025-4-7
You can make use of a mask for the subsystem through which you can set the colour and value of the output port label.
For more information about subsystem masks and the mask editor, you may refer this link - https://www.mathworks.com/help/simulink/gui/mask-editor-overview.html
Hope that solves your query!
回答(1 个)
colordepth
2025-4-17
编辑:colordepth
2025-4-17
As of MATLAB R2024b, there doesn't appear to be a built-in method to accomplish this using system objects. Moreover, attempting to modify the block mask programmatically results in an error, as illustrated below:

The only way to change the icon (including port labels and colors) for blocks using system objects is by using the mask editor. The steps suggested by @Raghava S N work well to achieve such customization.
Additional information: When you save a system object mask from the mask editor, it is serialized as an XML file in the same directory as your system object M-file. This means that both the system object and its mask customization code are accessible in one folder location, as shown below. However, any changes must be made through the mask editor.

0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Create Block Masks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!