save all variables of the workspace excluding the graphical objects within a function
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Bastien Haemmerli
le 26 Jan 2017
Réponse apportée : Walter Roberson
le 26 Jan 2017
Hello, I would like to define a function saving all the variables in the base workspace, excluding all figures object. the reason for trying to do it within a function is because I want to be able to define the name of the file where the variables will be saved and pass this name as argument to the function. I found a way to do it outside a function http://stackoverflow.com/questions/38131166/save-matlab-workspace-without-saving-or-deleting-figures but this won't work within a function as it will only save the local variables of the function.
I could go on without defining this function but it would be much better if I could set the name of the saved file without opening the .m file every time to change it.
Thanks in advance,
Bastien
0 commentaires
Réponse acceptée
Walter Roberson
le 26 Jan 2017
evalin('base', 'whos')
This will get you a structure with a list of variables. You can examine the class field to rule out ones that definitely not graphics. The ones that are left, you can loop through evalin base testing for graphics. In particular for R2014b or later, https://www.mathworks.com/help/matlab/ref/isgraphics.html . (But double-check what happens to graphics objects that have been marked as deleted.)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Object Programming dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!