필터 지우기
필터 지우기

Dynamically change block mask to display input signal names

조회 수: 16 (최근 30일)
I'm using an if/else subsystem block, and I would rather see meaningful names on the conditions instead of just a port number. For example, if my first input port is from signal My_Timer, and my condition is u1<10, I'd rather see the port labeled as "My_Timer" and the condition as "if(My_Timer < 10)" instead of port labeled as "u1" and condition as "if(u1 < 10)".

채택된 답변

MathWorks Support Team
MathWorks Support Team 2022년 11월 3일
If this is a one-time fix to display signals names, you can create a mask and edit the port labels in the mask "Icon" tab. For dynamic changes, follow the steps below:
To create the workaround to support your desired workflow, you need to place the “If” block inside of a masked subsystem and add a callback function to the input port. This callback will execute whenever a signal is connected to that port. Here are general steps to implement this function so that it will change the name of the ports in the masked subsystem based on the name of the input signal.
This allows the subsystem inport to inherit the name of the signal line entering it. Inside the same callback you can also change the name of the outport to also reflect the input signal name.
If you would like to reuse this block across your project, place it in a custom library. For the callback to work you will just need to ensure that the callback function is in the MATLAB path and that the ‘Allow library blocks to modify its contents’ check is enabled under the ‘Code’ tab in the Mask Editor.
This documentation link may also prove helpful:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subsystems에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by