3

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?

B Seven
  • 44,484
  • 66
  • 240
  • 385
  • 1
    Related/Possible duplicate http://stackoverflow.com/questions/9104326/loading-a-variable-from-a-mat-file-into-a-differently-named-variable/ – Andrey Rubshtein Feb 02 '12 at 17:58

1 Answers1

9

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.

Andrew Janke
  • 23,508
  • 5
  • 56
  • 85