How to stop a Simulink Mask Callback from executing even when not opening the mask

4 views (last 30 days)
Hello, I am working with a complex model containing many initialization files and subsystems. To make it more convenient for users to change simulation parameters, I have implemented a set of empty masked blocks on the top level model file, where the masks contain controls to modify various simulation parameters.
For a simple example, the end time of the simulation comes from either a file, or a user-defined value. In the relevant mask, the user can pick 'Manual' or 'From File' from a popup, which changes the visibility of either an edit box to enter the end time, or a second popup to pick the file. The first popup callback changes the visibility of the edit box and second popup, and the box/2nd popup callbacks copy the value entered (or selected filename(end) value) to the MATLAB workspace variable that defines the simulation stop time. There are default values in the edit box and the two popups that load once via a PreLoadFcn model callback.
The problem I am having is that this approach does not seem to work consistently. When I select 'From File', the simulation end time variable in the MATLAB workspace changes appropriately, but after clicking Run and model compilation, the simulation end time variable changes to whatever is entered into the edit box for the 'Manual' option. If I select 'From File', close the mask, and re-open it, the simulation end time variable changes even though the first popup still says 'From File'. It's like the 'Manual' callback is being executed with every Mask open, and by itself when the model runs. There is no other place in the model where the values would be updated like this, so I know it's the mask.
What I would like to do is only have the workspace variables updated when the Apply and/or OK buttons are clicked in the mask dialog. How can I achieve this? Thanks!

Answers (0)

Categories

Find more on Author Block Masks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!