MATLAB: Retrieve mat-file version

file formatmatfileMATLABmatlab.io.matfiletype

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
David

Best Answer

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');
end