How to call a script BEFORE opening a Simulink subsystem?
3 views (last 30 days)
Show older comments
When the user double clicks a Simulink subsystem, I would like to call a MATLAB .m script (to check if the block is a disabled library link, and issue a warning if the associated model file is not "locked" in the version control system), and then open the subsystem normally.
- By using the OpenFcn callback, I can only call the script INSTEAD of opening the subsystem.
- When I write an OpenFcn callback that calls the script and then calls open_system to open the subsystem, I get an error message which says I must not call OpenFcn recursively.
I'm using MATLAB version 2012b.
Any ideas would be appreciated!
0 Comments
Answers (1)
Sebastian Castro
on 2 Oct 2014
Kurt,
I'd like to step back a little, if that's okay.
1. There is a display option on Simulink models that visual cues (badges) based on library links status. To access it, you can select Display > Library Links from the Simulink menu.
2. Alternatively, you could always run a model-wide check to test for disabled library links. You could write your own by searching through using the find_system function, or you can use built-in Model Advisor (Analysis > Model Advisor > Model Advisor) and run some of these checks.
Best, Sebastian
2 Comments
Sebastian Castro
on 2 Oct 2014
Well, how about this?
You can create a mask for your Subsystem block (right-click, select Mask > Create Mask ).
In the Initialization tab, you can add the following code:
Then, when your links are disabled you'll actually get a warning pop-up dialog! However, this won't be immediately when you open the block -- this will happen when the model updates before simulation, or when you hit Simulation > Update Diagram .
See Also
Categories
Find more on Subsystems in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!