mfileread

版本 1.0.0.0 (1.7 KB) 作者: Mathias Benedek
This function separately returns the code part and the comment part of an m-file
385.0 次下载
更新时间 2010/12/19

查看许可证

This function reads a Matlab m-file, trims the content (removing empty lines and unnecessary spaces), and divides the content into code and comment part.
It returns a struct with fields holding information on the number of non-empty lines, and three strings representing the whole text, the code part, and the comment part.

This function can be used to access and analyze code and comments seperately.
It could e.g. also be used to generate a trimmed copy of an m-file with all comments removed by entering

mfinfo = mfileread(fname);
fid = fopen(fname2, 'wt');
fprintf(fid,'%s',mfinfo.code);
fclose(fid)

引用格式

Mathias Benedek (2024). mfileread (https://www.mathworks.com/matlabcentral/fileexchange/29780-mfileread), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2008a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Text Files 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0