Reading all variable from a mat file.
조회 수: 4 (최근 30일)
이전 댓글 표시
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
Image Analyst
2013년 10월 30일
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
2013년 10월 31일
@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.
답변 (2개)
Azzi Abdelmalek
2013년 10월 25일
편집: Azzi Abdelmalek
2013년 10월 25일
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
2013년 10월 30일
편집: James Tursa
2013년 10월 30일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!