MATLAB: How to avoid the cell header from being displayed when I publish a MATLAB file in MATLAB 7.8 (R2009a)

MATLAB Report Generator

When I choose not to include the code in my published report, the cell headers for these code sections are still displayed in the table of contents as well as in the rest of the document.

Best Answer

In order to achieve this functionality, modify the m2mxdom.m file.
You need to make the following changing to this M2MXDOM.M file in order to avoid seeing the header titles:
1. Open the following folder outside MATLAB
MATLABROOT\toolbox\matlab\codetools\private
where MATLABROOT is the path returned by typing "matlabroot" at the MATLAB command prompt.
1. Create a copy of the m2mxdom.m file and rename the copy to m2mxdom_orignal.m
2. Edit the m2mxdom.m file
Around line 124 you should see
nextChunk = newChunk();
Replace the next line i.e. nextChunk.title = regexprep(ecToken{2},'^[ \t]*','');
with the following code
if iCodeBreaks == 1 %only do this for the first header else title is made blank
nextChunk.title = regexprep(ecToken{2},'^[ \t]*','');
else
nextChunk.title= '';
end
3. Save the file and publish the MATLAB file again.
4. You should not see any cell header in the generated report.