Implementing Multiple Workspaces for groups of functions/scripts
Mostrar comentarios más antiguos
While refurbishing a HIL simulation project, I came across the problem of categorizing the variables used in the different subsystems. These include the Drive Simulation, Energy Management System, Virtual Hardware, and the Interface to the Real Hardware. Now each of these are variants, and thus there are different configurations of which variants are active and which variables these variants load.
A GUI is supposed to allow easy access to all variables. This means that the variables are listed in different list boxes {Auto, Route, EMS, ...}. They are also to be saved as a group, and therefore they are required to be grouped. In addition, a set of functions and scripts will interact with the variables.
There are three ways I see of tackling this problem:
- Add a prefix to all variables, i.e. Hio_Rti1103_EStop = Hardware Input/Output (the block) _ Rti1103 (the variant) _ EmergencyStop (the variable). A script is can then use regex or something similar to find the relevant variables. These will then be saved in the 'base' workspace. For functions to access these, they will always have to use the 'evalin' function.
- Make a seperate 'workspace' as described here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/255044Using global, it would be possible to always have access to it.
- Finally, and IMHO my favorite, use a struct for each workspace. This allows further classification, as in a tree graph. The only problem I foresee is how to iterate through each level, if more than one level is used. The struct could then also be defined as global and be given a unique name as mentioned in 1.
I would love to hear what the recommended method is.
Kind Regards, Moritz Ulmer
1 comentario
Moritz Ulmer
el 20 de Mzo. de 2015
Respuestas (0)
Categorías
Más información sobre Workspace Variables and MAT Files en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!