how to get mat file version, type(matfile) doesn't work

22 次查看(过去 30 天)
Hi, I tried "type(matfilename)" to get the mat file version, but this command will type out the contents of the mat file, not the version. So how to get the version of a mat file? Thanks in advance!

采纳的回答

Walter Roberson
Walter Roberson 2020-4-15
fread() the first 16 bytes of the file.
'MATLAB 5.0 MAT-file' -> MATLAB 5.0 or 7.0 .mat file, saved with -v6 flag or with -v7 or (typically) with no -v flag
'MATLAB 7.3 MAT-file' -> MATLAB 7.3 .mat
no 'MATLAB' string at beginning but you know it is a .mat file -> .mat saved with -v4 flag
If you need to detect whether a file was stored with -v6 versus -v7 then there would be more work involved. The header does not differentiate between the two, but since -v6 does not support compression, it would be possible to look for clues such as the existence of compressed variables

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by