Including comments in a .mat file?

Is there any way to include comments (or similar) in a '.mat' file to indicate what the stored variables are?

답변 (3개)

Jos (10584)
Jos (10584) 2014년 2월 7일
편집: Jos (10584) 2014년 2월 7일

1 개 추천

Another option might be to use a structure:
A.values = [21 22 35]
A.label = 'temperature'
A.unit = 'degrees Celsius'
A.comment = 'measured with Pete''s device'
Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 7일
편집: Azzi Abdelmalek 2014년 2월 7일

0 개 추천

You can get those information. Look at this example
a=1;
b=2;
c=3;
save filename a b c
clear;
load filename
whos -file filename.mat
%or
data=load('filename')
var_names=fields(data)

댓글 수: 4

John Jendzurski
John Jendzurski 2014년 2월 7일
Thank you, Azzi. I should have been clearer in my original question. I not only want to know the names of the variables but also some descriptive information about the variables, eg. how the data was collected, what the variables represent, etc...something similar to comments that may be used in '.m' files.
Save with your data a string that contains your informations
a=1;
b=2;
c=3;
infos={'a is ' ; 'b is ' ;'c is ';' other infos' }
save filename a b c infos
John Jendzurski
John Jendzurski 2014년 2월 7일
That is a good idea. Thank you!
You can also create a function for each file you want to load
function filename
% comment1
% comment2
% .....
load filename
To load the file filename just type
filename
To see the comments type
help filename

댓글을 달려면 로그인하십시오.

Bjorn Gustavsson
Bjorn Gustavsson 2014년 2월 7일

0 개 추천

Sure, create a string describing everything, save that string variable.

댓글 수: 1

John Jendzurski
John Jendzurski 2014년 2월 7일
Thank you, Bjorn. This seems like a reasonable approach.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Variables에 대해 자세히 알아보기

제품

질문:

2014년 2월 7일

편집:

2014년 2월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by