How can I move variables into and out of a structure akin to LOAD and SAVE in MATLAB?
问题 Is there a quick way (i.e. one line) to dump a collection of variables "in" a structure, using the variable names as the structure fields? The "load" function basically does this but saving and loading to a temporary file seems ugly. For example: clear a = 'adsf' b = rand(10); x = var2struct(a,b) x.a x.b or better yet: x = var2struct(['a';'b']) Also, what about the reverse (i.e. dumping the field values to the current scope as variables named after the fields)?: clear x.a='asdf' x.b=rand(10);