Including comments in a .mat file?
Afficher commentaires plus anciens
Is there any way to include comments (or similar) in a '.mat' file to indicate what the stored variables are?
Réponses (3)
Jos (10584)
le 7 Fév 2014
Modifié(e) : Jos (10584)
le 7 Fév 2014
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
le 7 Fév 2014
Modifié(e) : Azzi Abdelmalek
le 7 Fév 2014
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 commentaires
John Jendzurski
le 7 Fév 2014
Azzi Abdelmalek
le 7 Fév 2014
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
le 7 Fév 2014
Azzi Abdelmalek
le 7 Fév 2014
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
le 7 Fév 2014
0 votes
Sure, create a string describing everything, save that string variable.
1 commentaire
John Jendzurski
le 7 Fév 2014
Catégories
En savoir plus sur Variables dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!