Guy on Simulink

Simulink & Model-Based Design

New Capabilities for Block Masking

Earlier this week, I had to debug an issue related to a block mask in MATLAB R2012b. This made me realize that I have not written about masking in a long time.

So many capabilities have been added in the last few years, I decided to highlight some of them in this post.

MATLAB R2012b

To begin, let's step back to five years ago. Here is what the Mask Editor looked like in MATLAB R2012b. At that time, all you could do was specify parameters one after the other, and the types available were limited to pretty much only edit, checkbox and popup.

Mask Editor in R2012b

MATLAB R2013b

In MATLAB R2013b, the Mask Editor was redesigned to allow more flexibility. Here is what it looked like:

Mask Editor in R2013b

This redesign allowed things like:

  • Specify location of the prompt (same or different row)
  • Place multiple parameters on one line
  • Group parameters within containers and tabs
  • Add action items like buttons and hyperlinks
  • Add images

Here is an example of what a mask dialog can look with those additions:

Mask example in R2013b

MATLAB R2018a

Now let's move forward to R2018a. As you can see, many new parameter and container types have been added:

Mask Editor in R2018a

Here is an example using dials, sliders, and the table container.

Mask example in R2018a

What's next?

To see examples of best practices when creating masks, I recommend typing slexMaskingExample in MATLAB or visit the Masking Example Models documentation page.

Here is an example I just put together to highlight how to modify images and text elements based on the choice of a popup parameter:

Dynamic Mask example in R2018a

To make it happen, I specified the following code in the parameter callback of the popup parameter:

Dynamic Mask example in R2018a, the code

Debugging Tip: While developing mask callback code, store it in a MATLAB script, and call this script from the Mask Editor. This will allow you to put breakpoints and debug your code easily.

Now it's your turn

Share your masking tips and experiences in the comments below.

|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.