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

mFileCells( fileLines )
function [mCells, noCells] = mFileCells( fileLines )
%
% Purpose : This function identified the segments the .m file which 
% correspond to cells
%
% It returen the indiced for the cells and the number of cells available
%
% 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:
%
noLines = length( fileLines );
%
%
sCells = [];
latexLines = [];
for k=1:noLines
    line = fileLines{ k };
    lineLength = length( line );
    if strcmp( line(1), '%' )
        if strcmp( line(2), '%' )
            sCells = union( sCells, k );
        end;
    end;
end;
%
sCells = sCells';
noCells = length( sCells);
eCells = zeros( size( sCells ));
%
% match the ends of the cells
%
for k=1:(noCells-1)
    eCells(k) = sCells(k+1) - 1;
end;
if noCells == 0
    error('There must be at least one cell in the file to be documented.');
else;
    eCells( noCells ) = noLines ;
end;
%
mCells = [sCells, eCells];

Contact us