How can I list which file format version was used for existing .MAT files?

Hi, we have a large application where Matlab .MAT files are stored on a network and shared between different users. These users run different versions of Matlab, ranging from v6.1 up to v8.2 (R2013B). In updating this application from v6.1, we initially did not recognize that the MAT file format had changed -- this has since been fixed. In the interim period, however, we inadvertently created a mix of .MAT files created with different versions of Matlab. I would like to list which version each .MAT file is stored in so that I can work on standardizing the file format to version 6. I have not been able to find any way to list the file version, however. Any ideas?
Thanks for your help.

답변 (1개)

Wayne King
Wayne King 2014년 1월 7일
편집: Wayne King 2014년 1월 7일
type('matfilename.mat')
Or the functional form
type matfilename.mat
Should give you the MAT file version and platform information.

댓글 수: 5

Tom
Tom 2014년 1월 7일
편집: Tom 2014년 1월 7일
Thank you, but I don't think this will help in this case. Unfortunately the "descriptive text" in the beginning of the MAT file is always something like "MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Mon Jan 06 10:21:28 2014" for any version after Matlab v5. So even though it says it's a MATLAB 5.0 MAT-file, Matlab v6.1 thinks it is corrupt if it is created with Matlab 8.2.
Those are the MAT file version. There are only 4 (v7.3,v7,v6,v4). V7 and V6 header look the same and V4 does not have a readable header. V7.3 is HDF based format and has a different header.
In which format did you save the MAT file in MATLAB 8.2? I pretty much doubt that you saved it in an older format which MATLAB v6.1 can handle.
Since MATLAB v6.1 is pretty old I would guess you would need to save the data as v4 format:
save('myfile.mat','myvariable','-v4')
But it does return the year it was created, can't you use that information?
Thank you Friedrich. If I just do a save command in Matlab R2013B (v8.2) the header always says "MATLAB 5.0 MAT-file". It says the same thing if I save it in Matlab v6.1 but the actual format is different. So, I think that's just the generic file format and that there are other version differences somewhere else in the file. I just don't know how to detect these and decode them into the true MAT-file version.
Wayne, using the date is a good idea, but we had multiple versions of Matlab running during the same time period, each saving MAT-files in their native format. I've fixed the code so that now they will all save using the '-v6' option, but I still need to clean up the mess from before the fix. So being able to identify the file format would be very helpful. Matlab can obviously determine this when it loads a file, but it's sure not obvious how to do this programmatically.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

제품

질문:

Tom
2014년 1월 7일

댓글:

Tom
2014년 1월 7일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by