필터 지우기
필터 지우기

Select an unknown variable from .Mat file

조회 수: 3 (최근 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 CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by