Is there a way to include a header comment for a mat file?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Scientists often have a lot of scripts which run particular analyses, and running doc on a directory is a great way to get a summary of what all the scripts/functions do:
>> doc('Max_1h_prcp')
Contents of Max_1h_prcp:
...
But for those mat files, well the summary is not so useful.
Is there any way to add a comment to a mat file, so it shows up in doc?
If not, would this be a function anyone else would like?
0 Kommentare
Antworten (1)
Walter Roberson
am 18 Sep. 2020
Unfortunately v4 and v5 and v7 mat files were not defined to allow for comments. The exception is that the first 128 bytes of v5 and v7 files is text and that everything after naming the version is ignored, so about 110 bytes are available.
In theory Mathworks could extend the v5 and v7 header to include a comment marked as such, but doing so would cause backwards compatibility problems.
v7.3 mat files are hdf5 files, and that standard has no provision for file comments. The standard does have an Object Comment that can be applied to each data object, but there is not one for the file level as far as I can see.
I suspect that the easiest approach would be to designate a particular variable name to store in the file as a file description, and to write a small wrapper that checks the file for that variable and pulls it out and displays it if present. You would need to decide between char() vs string() vs cell array of character vectors.
0 Kommentare
Siehe auch
Kategorien
Mehr zu HDF5 finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!