Is there a way to include a header comment for a mat file?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2020-9-18
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 HDF5 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!