retrieve mat-file version for v7.0

조회 수: 10 (최근 30일)
Matlab Pro
Matlab Pro 2024년 5월 13일
편집: Stephen23 2024년 5월 13일
Hi
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
Stephen23
Stephen23 2024년 5월 13일
편집: Stephen23 2024년 5월 13일
"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
□□□□□□□□□□□□□□□□□□□□X□□-DTû! @
type testv6.mat
MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Mon May 13 08:48:38 2024 □□□□□□□□□□IM□□□□8□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□X□□□ □□□□□□-DTû! @
type testv7.mat
MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Mon May 13 08:48:38 2024 □□□□□□□□□□IM□□□□8□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□X□□□ □□□□□□-DTû! @
type testv73.mat
MATLAB 7.3 MAT-file, Platform: GLNXA64, Created on: Mon May 13 08:48:38 2024 HDF5 schema 1.00 . □□□□□□□□□□IM□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□HDF □ □□□□□□□□□□□□□□□□□□□□ÿÿÿÿÿÿÿÿ□□□□□□□□ÿÿÿÿÿÿÿÿ□□□□□□□□`□□□□□□□□□□□□□□□□□□□□□□□¨□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□¨□□□□□□□TREE□□□□ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ□□□□□□□□8□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□HEAP□□□□X□□□□□□□□□□□□□□□È□□□□□□□□□□□□□□□X□□□□□□□□□□□□□□□H□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□(□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□ ?□□□□□@□4□□4ÿ□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□-DTû! @□□□□□□□□□□□□□□æÓAf□□0□□□□□□□ □MATLAB_class□□□□□□□□□□□□□□□□□□□□double□□□□@□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□SNOD□□□□□□□□□□ □□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
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)
ans = logical
1
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:

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

채택된 답변

Walter Roberson
Walter Roberson 2024년 5월 13일
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개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by