Code covered by the BSD License  

Highlights from
publish2latex

image thumbnail

publish2latex

by

 

09 Apr 2013 (Updated )

Using full Latex markup in m-files to generate high quality documentation. Version 1.3

readInTextFile( filePath, fileName )
function lines = readInTextFile( filePath, fileName )
%
% Purpose : This procedure reads in a text file. It may be an .m file or a
% .tex file.
%
% Author :  Matther Harker and Paul O'Leary
% Date :    29. Jan 2013
% Version : 1.0
%
% (c) 2013 Matther Harker and Paul O'Leary
% url: www.harkeroleary.org
% email: office@harkeroleary.org
%
% History:
%   Date:           Comment:
%

fid = fopen([filePath, fileName]);
if fid == -1
    error(['File could not be opened.',fileName]);
end;
%
% Count the number of lines
%
tLine = fgets(fid);
at = 0;
while ischar(tLine)
    at = at + 1;
    tLine = fgets(fid);
end;
%
noLines = at;
%
frewind( fid );
%
lines = cell( noLines, 1 );
tLine = fgets(fid);
at = 1;
while ischar(tLine)
    lines{at} = tLine;
    tLine = fgets(fid);
    at = at + 1;
end;
%
fclose( fid );

Contact us