mfileread
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)
Cite As
Mathias Benedek (2024). mfileread (https://www.mathworks.com/matlabcentral/fileexchange/29780-mfileread), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |