Code covered by the BSD License  

Highlights from
mfileread

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 1.69 KB File ID: #29780

mfileread

by Mathias Benedek

 

19 Dec 2010

This function separately returns the code part and the comment part of an m-file

| Watch this File

File Information
Description

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)

MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data import Mathias Benedek 20 Dec 2010 07:56:54
code Mathias Benedek 20 Dec 2010 08:06:13
read Mathias Benedek 20 Dec 2010 08:06:13
mfile Mathias Benedek 20 Dec 2010 08:06:13
comments Mathias Benedek 20 Dec 2010 08:06:13
text Mathias Benedek 20 Dec 2010 08:06:13

Contact us at files@mathworks.com