Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I determine the version of a MAT file from MATLAB?

I am wondering if there is a way to determine whether 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 having to load the data into memory.

like image 832
Berk U. Avatar asked Mar 31 '15 22:03

Berk U.


1 Answers

There is some comment at the beginning of mat-files version 6 or following. This code reads it:

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

It seems the comment is always 116 chars long, but I did not find any reference. This code reads 140 chars and cuts of at the end.

The part I don't understand: For Version 6 or 7 it says MATLAB 5.0 MAT-file

like image 72
Daniel Avatar answered Sep 20 '22 07:09

Daniel