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

prepareMCode( codeLines )
function executableMCode = prepareMCode( codeLines )
%
% Purpose : This function modifies the m code to be execture to ensure that
% all graphical objects are correctly acquired. It also supresses the clear
% to avoid loss of data.
%
% 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:
%

if ~isempty( codeLines )
    noCodeLines = length( codeLines );
    line1 = codeLines{1};
    eolChar = line1(end);
    %
    % scan for clear and remove
    %
    returnCodelines = [];
    for k=1:noCodeLines
        codeLine = codeLines{k};
        %
        % add a line if is not a clear line
        %
        inds = findstr( codeLine, 'clear' );
        if isempty( inds )
            returnCodelines = [returnCodelines, codeLine];
        end;
        %
        % If figure is called then add a line of code to capture the GCF.
        %
        inds = findstr( codeLine, 'figure' );
        if ~isempty( inds )
            returnCodelines = [returnCodelines, 'graphicHandels = [graphicHandels, gcf];', eolChar];
        end;
    end;
    %
    numberReturnLines = length( returnCodelines );
    executableMCode = [];
    %
    for k=1:numberReturnLines
        executableMCode = [executableMCode, returnCodelines(k)];
    end;
else
    executableMCode = [];
end;

Contact us