Simple Masked Subsystem Popup-Menu

1 次查看(过去 30 天)
Inside a masked subsytem, i want to have a block from Specialized Power System (SPS) that has a Pop-Up Menu. The block is the "Three-Phase Source (masked)" block. Within the block there is the Configuration box which is a Popup. How can i change the parameter of the Configuration from my own masked subsystem?

回答(1 个)

RANGA BHARATH
RANGA BHARATH 2023-7-4
Hi @Ahmed Ellithy. Here is the solution and code for your question.
Question: In a masked subsystem, I have a block from the Specialized Power System (SPS) library called 'Three-Phase Source (masked)'. This block contains a Configuration box with a Pop-Up Menu. How can I programmatically modify the parameter of the Configuration box within this block from my custom masked subsystem?
Solution:
To change the parameter of the Configuration box within the "Three-Phase Source (masked)" block from your own masked subsystem in Simulink, you can follow these steps:
  • Open your masked subsystem by double-clicking on it.
  • Right-click inside the masked subsystem and select "Create Mask Initialization Function" from the context menu. This will create an initialization function file for your masked subsystem.
  • Open the initialization function file (Ex: your_masked_subsystem_InitFcn.m) that was created in the MATLAB Editor.
  • Inside the initialization function, you can use the "set_param" function to modify the parameter of the Configuration box in the "Three-Phase Source (masked)" block. The syntax for "set_param" is as follows:
Code:
set_param('block_path/Configuration', 'ParameterName', 'ParameterValue');
  • Here, replace "block_path" with the path to the "Three-Phase Source (masked)" block within your masked subsystem, "Configuration" with the name of the Configuration box parameter, "ParameterName" with the actual parameter you want to modify, and "ParameterValue" with the new value you want to set.
  • Save the initialization function file.
Now, whenever you use your masked subsystem in your Simulink model, the initialization function will be executed, and the parameter of the Configuration box within the "Three-Phase Source (masked)" block will be set to the desired value.
Links to Documentation:
Here are some documentation links that you can refer to for more information:

类别

Help CenterFile Exchange 中查找有关 Event Functions 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by