How can I create a dynamic output port name that updates based on an action and change output text color using system object?

3 vues (au cours des 30 derniers jours)
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 commentaires
Raghava S N
Raghava S N le 7 Avr 2025
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!
Wilfried
Wilfried le 7 Avr 2025
Modifié(e) : Wilfried le 17 Avr 2025
Thank you Raghava for your response. I know about the mask editor, but I am trying to code it in the system object file without having to go to the mask editor if possible so I can have all the code in one file.

Connectez-vous pour commenter.

Réponses (1)

colordepth
colordepth le 17 Avr 2025
Modifié(e) : colordepth le 17 Avr 2025
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.

Catégories

En savoir plus sur Create Block Masks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by