MATLAB Function Reference Previous page   Next Page
publish

Run M-file script containing cells, and save results to file of specified type

Graphical Interface

As an alternative to the publish function, use the File -> Publish To menu items in the Editor/Debugger.

Syntax

Description

publish('script') runs the file named script, one cell at a time in the base workspace, and saves the code, comments, and results to an HTML output file. The output file is named script.html and is stored, along with other supporting output files, in an html subdirectory in script's directory.

publish('script','format') runs the file named script, one cell at a time in the base workspace, and publishes the code, comments, and results to an output file using the specified format. Allowable values for format are html (the default), xml, latex for LaTeX, doc for Microsoft Word documents, and ppt for Microsoft PowerPoint documents. The output file is named script.format and is stored, along with other supporting output files, in an html subdirectory in script's directory. The doc format requires Microsoft Word, and the ppt format requires PowerPoint. When publishing to HTML, the M-file code is included at the end of published HTML file as comments, even when the showCode option is set to false. Use the grabcode function to extract the code from the HTML file.

publish('script',options) publishes using the structure options, which can contain any of the following fields and corresponding value for each field. Create and save structures for the options you use regularly. For details about the values, see the description of the corresponding Editor/Debugger preferences for Publishing and Publishing Images preferences in the online documentation for MATLAB.

Field
Allowable Values
format
'doc','html' (default), 'latex', 'ppt', 'xml'
stylesheet
'' (default), XSL filename (used only when format is html, latex, or xml)
outputDir
'' (default, a subfolder named html), full pathname
imageFormat
'png' (default unless format is latex), 'epsc2' (default when format is latex), any format supported by print when figureSnapMethod is print, any format supported by imwrite functions when figureSnapMethod is getframe.
figureSnapMethod
'print' (default),'getframe'
useNewFigure
true (default), false
maxHeight
[] (default), positive integer specifying number of pixels
maxWidth
[] (default), positive integer specifying number of pixels
showCode
true (default), false
evalCode
true (default), false
stopOnError
true (default), false
createThumbnail
true (default), false

Examples

Publish to HTML Format

To publish the file d:/mymfiles/sine_wave.m to HTML, run

MATLAB runs the file and saves the code, comments, and results to d:/mymfiles/html/sine_wave.html. Open that file in the Web browser to view the published document.

Publish to Word Format with Options

This example defines the structure options_doc_nocode, publishes sine_wave.m using the defined options, and displays the resulting file. The resulting file is a Word document, d:/nocode_output/sine_wave.doc and includes results, but not MATLAB code.

See Also

grabcode, notebook

MATLAB Desktop Tools and Development Environment documentation topics


Previous page  psi pwd Next page

© 1994-2005 The MathWorks, Inc.