Copy Block Mask GUI from Model to MATLAB App

38 views (last 30 days)
Daniel Flisek
Daniel Flisek on 30 Oct 2024 at 19:48
Answered: Divyajyoti Nayak on 19 Nov 2024 at 4:11
I have a MATLAB app that interfaces with Simulink models. The app reads the model to determine what inputs the model needs, then creates and displays edit fields in the app GUI for user input. When the app runs the model, it passes the values of these variables to the model's local workspace. Right now, the app just grabs all the input blocks, makes edit fields for all of them, and puts them all on the GUI in whatever order they come in.
Some models, however, have inputs that should be grouped together in the app GUI. Instead of hard coding the app for certain situations, I would like to create a block mask in the model and "import" that into the app GUI. The app would copy and paste the mask GUI into an empty space in a grid layout.
I can group inputs together however I like in the block mask, and I want those groupings to be transferred to the app. This way the app doesn't need to know anything about the model or its inputs; it just has to grab and display the mask.
Is it possible to programmatically retrieve the block mask GUI from a Simulink model, and directly use it in a MATLAB App?

Answers (1)

Divyajyoti Nayak
Divyajyoti Nayak on 19 Nov 2024 at 4:11
Hi Daniel,
To programmatically get the mask of any block in a Simulink model, the ‘get’ function of the ‘Simulink.Mask’ class can be used. Here’s the documentation and some sample code to help you out:
openExample('simulink_masking/MaskLookupTableControlExample')
Simulink.Mask.get('slexMaskLookupTableControlExample/LUT Control with Explicit Data');

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!