3
votes

Apparently Matlab load loads the data from a .mat file into the variable that it was saved.

How can you load a single matrix from a .mat or binary file into an arbitrary variable?

1

1 Answers

9
votes

Load it in to a struct and pop it out to your variable.

saved_name = 'varname_it_was_saved_as';
s = load('some_file.mat', saved_name);
my_new_variable = s.(saved_name);

I always use the struct forms of save and load for production code. It's cleaner because it doesn't dynamically fiddle with your workspace.

See help load for details.