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.
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.
In MATLAB R2013b, the Mask Editor was redesigned to allow more flexibility. Here is what it looked like:
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:
Now let's move forward to R2018a. As you can see, many new parameter and container types have been added:
Here is an example using dials, sliders, and the table container.
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:
To make it happen, I specified the following code in the parameter callback of the popup parameter:
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.
要发表评论，请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。