Including comments in a .mat file?

6 ビュー (過去 30 日間)
John Jendzurski
John Jendzurski 2014 年 2 月 7 日
編集済み: Jos (10584) 2014 年 2 月 7 日
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 日
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 日
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 日
That is a good idea. Thank you!
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 7 日
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 日
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.

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

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by