Desktop Tools and Development Environment Previous page   Next Page

Publishing M-Files Using Cells

When you publish an M-file that contains cells and text markup, MATLAB produces an output document consisting of the M-file code, comments, and results.

How to Publish an M-File

After adding cells and text markup to an M-file, select File -> Publish To and select an output format from those listed in the menu: HTML, XML, LaTeX, Word, or PowerPoint. If the M-file contains unsaved changes, the menu item becomes Save and Publish To.

You can also publish to the default output format specified in Preferences using the Publish button in the Editor/Debugger toolbar.

MATLAB displays the published document in the appropriate tool for the selected output format:

The published file contains the formatted comments, code including syntax highlighting, and results (in gray to distinguish it from code) for each cell, and for all cells in the M-file. When code produces a figure, the last figure generated in a cell appears in the published file. It also contains a Contents heading at the top of the file with a bulleted list of links to the named cells in the rest of the document.

When publishing to HTML, the M-file code is included at the end of published HTML file as comments. Use the grabcode function to extract the code from the HTML file.

Function Alternative

From the Command Window, run the publish function to run the M-file and publish the results. See the publish function reference page for options you can set.

Previous page  Marking Up Text in Cells for Publishing About Published M-Files Next page

© 1994-2005 The MathWorks, Inc.