simulink mask callback adding variables to workspace
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Amish Rughoonundon
am 1 Mär. 2016
Kommentiert: Sebastian Castro
am 2 Mär. 2016
Hi, I have a subsystem with a mask and a callback function based on what option the user chooses in the mask dialogue. I set some variables in the callback function as below
rev = 1
The variable appears in the matlab workspace. Is there a way to keep the variable from appearing in the workspace but still be able to use it in the callback function code? Thanks, Amish
0 Kommentare
Akzeptierte Antwort
Sebastian Castro
am 2 Mär. 2016
Bearbeitet: Sebastian Castro
am 2 Mär. 2016
You can take all that initialization code and move it from a block callback to the "Initialization" tab of the Mask Editor. The variables created will belong only to the masked block's workspace, so they cannot be tampered with in the base workspace.
- Sebastian
2 Kommentare
Sebastian Castro
am 2 Mär. 2016
Well, the callbacks work for any block -- whether it is a masked subsystem or not.
With a masked subsystem, you get the advantage of having a local block workspace, which lends itself out for self-contained initialization code.
On the other hand, block callbacks give you control of other events besides initialization. There's a whole list of them including copy, paste, open (double-click), etc. so there's more freedom to insert code snippets at key instances if you need to.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Author Block Masks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!