MATLAB Answers

David T_

retrieve mat-file version

David T_
さんによって質問されました 2012 年 8 月 30 日
最新アクティビティ Walter Roberson
さんによって コメントされました 2017 年 8 月 23 日
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

  0 件のコメント

サインイン to comment.

2 件の回答

Daniel Shub
回答者: Daniel Shub
2012 年 8 月 30 日

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

  4 件のコメント

2012 年 8 月 30 日
I'd have thought there'd be an easier way to determine it? You can also do it through fscanf
but it still seems overly complicated.
Daniel Shub
2012 年 8 月 30 日
I was really answering the "you cannot use TYPE within a function" part of the question. I am not sure you want to use TYPE, but I wanted to provide a way to do it.
Walter Roberson
2017 年 8 月 23 日
You can also use fileread() to pull in the entire file, and then examine the first few characters of it.

サインイン to comment.

回答者: Tom
2012 年 8 月 30 日

should work fine, where FileName is a string containing the file name, e.g.

  0 件のコメント

サインイン to comment.

Translated by