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:

mask

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')    
open_system(path,'tab');
end

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 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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top