How can I remove a variable from the parent workspace while a function is using it?
Mostrar comentarios más antiguos
I work with fairly large datasets, so the fact that they get duplicated when a function accepts them as an input can be a problem given 32bit memory constraints.
I have started using scripts instead of functions in order to save on memory usage, but this has caused additional problems, because now their is no distinction between the workspaces and I have to be very careful not to overwrite utility variables (such as x, y, t, n, etc.)
I would really like to pass a variable as a function input such that there are not two copies floating around the system.
How can I remove the variable from the parent workspace (or possibly act directly on only the parent workspace variables that are specified as functional inputs?)
Thanks, Sean
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 14 de Dic. de 2011
To answer the original question:
evalin('caller', ['clear ', inputname(3)])
where the 3 here should be changed to the parameter number of the variable in the calling sequence.
Crashes due to doing this would not surprise me.
1 comentario
Sean
el 14 de Dic. de 2011
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!