{"id":7670,"date":"2018-06-29T12:35:00","date_gmt":"2018-06-29T17:35:00","guid":{"rendered":"https:\/\/blogs.mathworks.com\/simulink\/?p=7670"},"modified":"2018-06-29T12:35:00","modified_gmt":"2018-06-29T17:35:00","slug":"new-capabilities-for-block-masking","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2018\/06\/29\/new-capabilities-for-block-masking\/","title":{"rendered":"New Capabilities for Block Masking"},"content":{"rendered":"<p>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.<\/p>\n<p>So many capabilities have been added in the last few years, I decided to highlight some of them in this post.<\/p>\n<p><strong>MATLAB R2012b<\/strong><\/p>\n<p>To begin, let's step back to five years ago. Here is what the <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/gui\/mask-editor-overview.html\">Mask Editor<\/a> 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 <em>edit<\/em>, <em>checkbox <\/em>and <em>popup<\/em>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q2\/maskR2012b.png\" alt=\"Mask Editor in R2012b\" \/><\/p>\n<p><strong>MATLAB R2013b<\/strong><\/p>\n<p>In MATLAB R2013b, the Mask Editor was redesigned to allow more flexibility. Here is what it looked like:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q2\/maskR2013b.png\" alt=\"Mask Editor in R2013b\" \/><\/p>\n<p>This redesign allowed things like:<\/p>\n<ul>\n<li>Specify location of the prompt (same or different row)<\/li>\n<li>Place multiple parameters on one line<\/li>\n<li>Group parameters within containers and tabs<\/li>\n<li>Add action items like buttons and hyperlinks<\/li>\n<li>Add images<\/li>\n<\/ul>\n<p>Here is an example of what a mask dialog can look with those additions:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q2\/maskExampleR2013b.png\" alt=\"Mask example in R2013b\" \/><\/p>\n<p><strong>MATLAB R2018a<\/strong><\/p>\n<p>Now let's move forward to R2018a. As you can see, many new parameter and container types have been added:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q2\/maskR2018a.png\" alt=\"Mask Editor in R2018a\" \/><\/p>\n<p>Here is an example using dials, sliders, and the table container.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q2\/maskExampleR2018a.png\" alt=\"Mask example in R2018a\" \/><\/p>\n<p><strong>What's next?<\/strong><\/p>\n<p>To see examples of best practices when creating masks, I recommend typing <tt>slexMaskingExample<\/tt> in MATLAB or visit the <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/masking-example-models.html\">Masking Example Models documentation page<\/a>. <\/p>\n<p>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:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q2\/dynamicDialog.gif\" alt=\"Dynamic Mask example in R2018a\" \/><\/p>\n<p>To make it happen, I specified the following code in the parameter callback of the popup parameter:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q2\/maskCode.png\" alt=\"Dynamic Mask example in R2018a, the code\" \/><\/p>\n<p><em><strong>Debugging Tip:<\/strong> 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.<\/em><\/p>\n<p><strong>Now it's your turn<\/strong><\/p>\n<p>Share your masking tips and experiences in the comments below.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q2\/maskCode.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>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.<br \/>\nSo many capabilities have been added in... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2018\/06\/29\/new-capabilities-for-block-masking\/\">read more >><\/a><\/p>\n","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[47],"tags":[452],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/7670"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=7670"}],"version-history":[{"count":17,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/7670\/revisions"}],"predecessor-version":[{"id":7728,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/7670\/revisions\/7728"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=7670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=7670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=7670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}