Save all workspace within a function
Mostrar comentarios más antiguos
Hello everybody! I'm trying to save the all workspace using the function save within a function. Unfortunately, if I do that, it saves only the local variables of the function, while I would like to save the global workspace. Is there a way to do that, which is not declare all variables as global variables?
Thank you!
3 comentarios
Adam
el 18 de Abr. de 2015
Why can't you just save the workspace variables from the workspace? One of the key points of a function is that it has its own scope and isn't contaminated by all the variables outside it.
Baham91
el 19 de Abr. de 2015
Adam
el 20 de Abr. de 2015
I see you accepted Geoff's answer so I assume that achieved what you want, although the exact nature of what you are aiming for still seems a little unclear. As far as I understand it, using that approach will save the workspace variables to file, but those workspace variables will be exactly the same as they were at the point you called the function unless you are using OOP with handle-derived classes or doing some ghastly assignin type behaviour within your function.
I would have thought that the progress which you mention would be encapsulated within your function, not in the base workspace.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Whos en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!