How to determine MAT file version from MATLAB?

I am wondering if there is a way to determine if a particular MAT file is v4, v6, v7 or v7.3?

I am looking for a solution that can determine the version using MATLAB code, preferably without the need to load data into memory.

+6
source share
1 answer

At the beginning of the mat files of version 6 or lower there is some comment. This code reads:

function txt=getMatComment(x) fid=fopen(x); txt=char(fread(fid,[1,140],'*char')); txt=[txt,0]; txt=txt(1:find(txt==0,1,'first')-1); end 

The comment seems to be always 116 characters long, but I did not find the link. This code reads 140 characters and abbreviations at the end.

Part I don't understand: for version 6 or 7 it says MATLAB 5.0 MAT-file

+5
source

Source: https://habr.com/ru/post/984529/


All Articles