注册 | 登录

解决matlab - How to implement a button into Simulink Subsystem Mask?

itPublisher 分享于



As I need to specify a local variable to a Subsystem, I created a mask. Doing that I lose the easy access to the subsystem. Right-click and navigating to "Look under mask" is supposed to be too complicated.

So I thought about a workaround and built the following:

The dialog callback code behind the "Get deeper!" checkbox is:

myParameter = %Parameter set by checking Get deeper!
path = gcb(gcs);

if strcmp(get_param(gcb,'myParameter'),'on')    

Everytime when I check the box, the subsystem gets opened and also by every double click on the subsystem, in case the box was checked before. Hence the code does what it should, but thats actualy not the common way how one would realize/visualize something like this.

What I want is a button "Look under mask" in my mask - so the subsystem just gets opened by clicking on that button. Basically the button should call the function: open_system(gcb(gcs),'tab'). Looks so easy, but Simulink doesn't offer me any option to implement this. Can anybody help?

The main issue whith the current solution is also that with every execution of the model all subsystems open up, where the box is checked. That's not the idea.

matlab simulink masking
edited Sep 25 '13 at 13:33 asked Sep 25 '13 at 9:15 thewaywewalk 20.9k 6 38 82


1 Answers


Matlab 2012b adds exactly what you want: masked blocks have a button on the botton left that is a shortcut to "Look under mask".

Unfortunately, I don't think it is possible to add a button in a mask.

You may want to change your function to automatically set the "Get deeper!" checkbox off after the user clicks on it. That would avoid the automatic opening of the subsystems when the model is loaded. You could do that adding set_param(path,'myParameter','off') just after the open_system(path,'tab');

Finally, as another workaround, you may want to set the OpenFcn callback to call open_system(gcb,'tab'). This will make the system work as if it isn't masked at all. You can put two open_system calls, one to look under mask and the other to open the mask dialog box, if you prefer.

edited Sep 25 '13 at 16:11 answered Sep 25 '13 at 11:00 nonDucor 84 3      Really? I have Matlab 2013a and 2012a and both don't have the button ;) I also found this: Is there a way to add another button to a mask in Simulink? which works fine for plots, but not for my case. What you suggested is what I'm trying to implenent for hours now. If you could provide some code you would help me a lot. I try "initialize" the checkbox as off, so it's unchecked everytime when I double click and for very simulation. But I'm not able to make it work. –  thewaywewalk Sep 25 '13 at 11:40      @thewaywewalk it's the little down arrow in the bottom left corner of the masked subsystem. It was introduced in R2012b, see –  am304 Sep 25 '13 at 12:02      From the release notes: "The [look under mask] badge does not appear for masks of library links if the library is locked or its LockLinksToLibrary property is set to true." –  am304 Sep 25 '13 at 12:03      @am304 - okay I found it, but anyway, it has to work under 2012a as well. –  thewaywewalk Sep 25 '13 at 12:07      @nonDocur - why does set_param(gcb,'myParameter','off') in the Initialization tab not work? –  thewaywewalk Sep 25 '13 at 12:10  |  show more comments








您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱