retrieve mat-file version for v7.0
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Matlab Pro
am 13 Mai 2024
Bearbeitet: Stephen23
am 13 Mai 2024
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 Kommentar
Stephen23
am 13 Mai 2024
Bearbeitet: Stephen23
am 13 Mai 2024
"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:
Akzeptierte Antwort
Walter Roberson
am 13 Mai 2024
The difference between -v5 and -v7 has to do with the variety of objects that are stored. If a particular .mat file does not happen to use any of the extended objects, then the -v7 version of it is the same as the -v5 version of it.
So in theory you could scan the .mat and discover at least one extended object, and that would prove that it is -v7 -- but if you do not find any extended objects then you cannot tell for sure whether it is -v5 or -v7
0 Kommentare
Weitere Antworten (0)
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!