MATLAB Function Reference |
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','
runs the file named format
')
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',
publishes using the structure options
)
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 |
|
'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 |
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.
options_doc_nocode.format='doc'
options_doc_nocode.outputDir='d:/nocode_output'
options_doc_nocode.showCode=false
publish('d:/mymfiles/sine_wave.m',options')
winopen('d:/nocode_output/sine_wave.doc')
See Also
MATLAB Desktop Tools and Development Environment documentation topics
psi | pwd |
© 1994-2005 The MathWorks, Inc.