retrieve mat-file version

108 views (last 30 days)
David T_
David T_ on 30 Aug 2012
Commented: Walter Roberson on 23 Aug 2017
Hello community,
I want to use the MATFILE command to access specific data in .mat-files. Is there a function which returns true if the .mat-file format is 'v7.3' and false otherwise?
I know you can check this in the command window using
type myfile.mat
However you cannot use TYPE within a function, which is what I want to do.
Thanks in advance

Accepted Answer

Daniel Shub
Daniel Shub on 30 Aug 2012
You can use evalc to capture the output of type
function tf = getmatv(fname)
x = evalc(['type(''', fname, ''')']);
tf = strcmp(x(2:20), 'MATLAB 7.3 MAT-file');
Walter Roberson
Walter Roberson on 23 Aug 2017
You can also use fileread() to pull in the entire file, and then examine the first few characters of it.

Sign in to comment.

More Answers (1)

Tom on 30 Aug 2012
should work fine, where FileName is a string containing the file name, e.g.

Community Treasure Hunt

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

Start Hunting!