Select an unknown variable from .Mat file

1 回表示 (過去 30 日間)
Evans Gyan
Evans Gyan 2018 年 2 月 5 日
コメント済み: Paul Richardson 2020 年 11 月 26 日
A .mat file has the variables
stateman
Name Size Bytes Class Attributes
val 1x1000 8000 double
Statefam
Name Size Bytes Class Attributes
statelab 1x16999 135992 double
ingrate 1x1 8 double
I want to automatically pick the variable with largest byte from a .mat file when selected by a user. Thank you guys
  2 件のコメント
Jan
Jan 2018 年 2 月 5 日
I have edited the question to make it readable. See http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup. Didn't you see, that the missing format impedes the readability?
Evans Gyan
Evans Gyan 2018 年 2 月 6 日
Well noted Jan

サインインしてコメントする。

採用された回答

Jan
Jan 2018 年 2 月 5 日
matObj = matfile('YourFile.mat');
details = whos(matObj);
[maxBytes, index] = max([details.bytes]);
maxName = details(index).name;
Now explain what "pick the variable" means. Do you want to import this variable?
data = matObj.(maxName);
% Or
data = load('YourFile.mat', maxName)
  1 件のコメント
Paul Richardson
Paul Richardson 2020 年 11 月 26 日
I had a similar question; this answer has helped a lot, so many thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by