Load a .mat file into another file without accesing variable name from .mat file

459 Views Asked by At

this problem is very annoying. The situation is like this, I am having .mat file with only a single variable in it. I am interesting in loading it in another variable without accessing the variable from the file tha t I am trying to load. Right, now I have tried something like this but with no effect:

  A=[];
  details=whos(FileName);
  aux=load(FileName,upper(details.name);  
  A=aux.(details.name);
1

There are 1 best solutions below

1
On BEST ANSWER

Since your MAT file has only one variable in it, you can load the whole thing and extract the name you want from there:

aux=load(FileName);
names=fieldnames(aux);
A=aux.(names{1});