Reading all variable from a mat file.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi
I am experiencing a some trouble reading data from a mat file. The file is created by a SW made by Agilent, which is to log data from a digital multi meter.
This SW makes it possible to save data in mat-format, which I did.
When I load the mat file in matlab I cannot get all the data. But when I look at the variable content in the view'er, I get the image shown below

When I use "whos" to find out about the content of the file. It seems like it finds all seven variable called "Data". The result from whos is shown below

When I use load function to read mat files I get only the last variable called "Data".
1. had an impression that it was not possible to have variables with the same name, how come this is possible?
2. How do I get the values from all "Data" variables
br Arun
5 Kommentare
Image Analyst
am 30 Okt. 2013
How did you get t? Didn't you do something like
t = load(yourMatFileName);
whos t
Then t should have all the data, like you showed, where each structure in the t structure array contains one version of data. So t(1).Data = the first data array, t(2).Data = the second array, or something like that.
James Tursa
am 31 Okt. 2013
@Image Analyst: I believe Arun is getting the above information with the whos function and with the variable viewer ... he isn't actually loading any of these variables to get that "header" information. It is when he does attempt to load them that they end up overwriting each other and he ends up with only the last one.
Antworten (2)
Azzi Abdelmalek
am 25 Okt. 2013
Bearbeitet: Azzi Abdelmalek
am 25 Okt. 2013
How can you have multiple variables with the same name? one name, one variable
a=10;
a=20% will erase the first content of a
James Tursa
am 30 Okt. 2013
Bearbeitet: James Tursa
am 30 Okt. 2013
The new version of LOADFIXNAMES is now available on the FEX. You can find it here:
It will load all of the variables it finds in the mat file and change any duplicate names to avoid name clashes. So your Data, Data, Data, etc variable names will get loaded as Data, Data00002, Data00003, etc. This new version has undergone only a limited amount of testing but it appears to be working as expected. Let me know if you have any problems.
While I was in the code I went ahead and added the capability to return a struct as an output instead of loading variables directly itno the workspace (just like the regular LOAD function allows).
You might consider contacting Agilent to let them know that their s/w is creating an invalid mat file with duplicate names.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Workspace Variables and MAT Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!