Effacer les filtres
Effacer les filtres

retrieve mat-file version for v7.0

9 vues (au cours des 30 derniers jours)
Matlab Pro
Matlab Pro le 13 Mai 2024
Modifié(e) : Stephen23 le 13 Mai 2024
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 commentaire
Stephen23
Stephen23 le 13 Mai 2024
Modifié(e) : Stephen23 le 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
□□□□□□□□□□□□□□□□□□□□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:

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 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

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by