0

Possible Duplicate:
How can I move variables into and out of a structure akin to LOAD and SAVE in MATLAB?

I was wondering if anybody knows of a function or a contribution in the Mathworks file exchange repository that allows me to group and ungroup variables in a similar way save and load does

Let me explain this better with an example:

/* The variables 'one_variable', 'another_variable' and 'yet_another_variable' already exist in the workspace and are (possibly) of different types*/

/* The function group_variables, that is called next, outputs a struct that holds the variables that are passed to it as input arguments*/

group = group_variables('one_variable', 'another_variable', 'yet_another_variable', etc..);

/* e.g. group is built as follows: group.one_variable, group.another_variable, etc..*/

/* Now, the function "ungroup_variables" returns the variables 'one_variable' 'another_variable' & 'yet another variable' in the workspace where the function is called:*/

ungroup_variables(group);

/* Now I can reference the variables 'one_variable', 'another_variable', 'yet another variable', etc.. as before.*/
Community
  • 1
  • 1
Amelio Vazquez-Reina
  • 83,134
  • 124
  • 340
  • 545
  • 4
    This was actually covered before: [matlab: dump variables into a structure](http://stackoverflow.com/questions/3470654/matlab-dump-variables-into-a-structure) – gnovice Sep 30 '10 at 21:35
  • @gnovice: should have checked first, I guess :) – Jonas Sep 30 '10 at 21:42
  • @Jonas: It's tough to find the duplicates sometimes if the Related list on the side hasn't been created yet (it usually takes more question views to appear). I only knew because I had answered it, and it still took me some effort to find it. ;) – gnovice Sep 30 '10 at 21:44
  • SO search capabilities have room for improvement. Faced the same problem today as @gnovice. – zellus Sep 30 '10 at 22:02
  • 4
    Here is another related question with a cool solution: http://stackoverflow.com/questions/1823668/is-there-a-way-to-push-a-matlab-workspace-onto-a-stack – yuk Sep 30 '10 at 23:56

0 Answers0