可能重复:
How can I move variables into and out of a structure akin to LOAD and SAVE in MATLAB?
我想知道是否有人知道Mathworks文件交换存储库中的函数或贡献,它允许我以类似的方式对变量进行分组和取消组合保存和加载
让我用一个例子更好地解释这个:
/* 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.*/