Simple Masked Subsystem Popup-Menu

1 visualización (últimos 30 días)
Ahmed Ellithy
Ahmed Ellithy el 3 de Jul. de 2023
Respondida: RANGA BHARATH el 4 de Jul. de 2023
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?

Respuestas (1)

RANGA BHARATH
RANGA BHARATH el 4 de Jul. de 2023
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:

Categorías

Más información sobre Subsystems en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by