MATLAB: How to use a popup (dropdown) control to dynamically change values in other edit boxes in the mask for a subsystem

callbackchangecontroldynamicallymaskpopupsimulinksubsystem

I have several different scenarios in a subsystem which I want to choose using a Popup control in a Simulink mask. How can I dynamically populate information in other control objects in the mask dialog with information based on what is currently selected in the Popup control?

Best Answer

Please refer to the the attached example that demonstrates using a Popup control's callback to change the values of two separate Edit controls in a mask.
This is possible by using the 'Callback' property of the Popup control. All variables and functions which can be used in the base MATLAB workspace can be used in control callbacks in a mask. This includes the use of the functions "get_param" and "set_param" to change different dialog variables in the mask.
The attached example primarily uses the functions "get_param" and "set_param" with "gcb" to get and set the values needed in the mask. This can be extended to incorporate other types of control that are also accessible using the "set_param" function.