Suppose I have access to a struct that was created using the load function:
structWithVariables = load('data.mat');
I want to load all the variables from this struct into workspace, but I cannot find any way of doing that without hardcoding the names of all variables.
Note: I don't have access to the .mat file, nor the code that loads the struct, I really only have the struct.
Note 2: the reason I want to do that is just to use some code that references the variables as if they are in the workspace. I don't want to change the code.
fieldnamesandassigninto assign them in to your workspace.evalfor this is now discouraged by Mathworks in favour of dynamic fieldnames (as used in Andrew's answer) blogs.mathworks.com/loren/2005/12/13/…