retrieve mat-file version for v7.0
Show older comments
Hi
Referring https://www.mathworks.com/matlabcentral/answers/47013-retrieve-mat-file-version?s_tid=sug_su
We can tell the mat-file version by viewing its 1st header line using type(FileName)
This works well for:
- version 5.0 file (created using '-v6' switch)
- Header: "MATLAB 5.0 MAT-file, Platform: PCWIN64.."
- version 7.3 file (created using -'-7.3' switch)
- Header "MATLAB 7.3 MAT-file, Platform: PCWIN64, "
For vestion 7.0 files (created with "-v7") switch) - the header still says it is vestion 5.0
Any idea how to get the "7.0" number from the file/meta data?
1 Comment
"Any idea how to get the "7.0" number from the file/meta data?"
In general this is impossible... for the simple reason that the 5.0 MAT files can be exactly identical depending on the options used when saving. For example, both SAVE options -v6 and -v7 -nocompression produce exactly the same files (scroll right to view the data):
X = pi;
save testv4.mat X -v4
save testv6.mat X -v6
save testv7.mat X -v7 -nocompression
save testv73.mat X -v7.3 -nocompression
type testv4.mat
type testv6.mat
type testv7.mat
type testv73.mat
So the flags -v6 and -v7 -nocompression can generate 5.0 MAT files which may be bit identical, i.e. which flag was used when SAVEing is not determinable from the file data alone:
tv6 = fileread('testv6.mat');
tv7 = fileread('testv7.mat');
isequal(tv6,tv7)
In a sense, SAVE's VERSION option is a misnomer: it is really a supported feature flag to enable different supported features when saving the files (e.g. Unicode, compression), rather than any specific differences in the file format itself. See also:
And if you really want to understand the 4.0 and 5.0 MAT file formats:
Accepted Answer
More Answers (0)
Categories
Find more on Standard File Formats in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!