publish
Generate view of MATLAB file in specified format
Syntax
Description
publish(
generates a view of
the specified MATLAB® code file and output in an HTML format that can be used for
sharing. file
)publish
saves the HTML file and a file for each
graphic that the code creates in a subfolder named html
. The
location of the html
subfolder is relative to the location of
file
.
For example, publish('C:\myMATLABfiles\myfile.m')
runs the
code in myfile.m
using the base workspace, and then saves the
formatted code and results in
C:\myMATLABfiles\html\myfile.html
.
publish(
generates a view of the specified MATLAB file with options specified by one or more
file
,Name,Value
)name,value
pair arguments.
publish(
uses the file
,options
)options
structure to generate the view of the
specified MATLAB file. Using a structure to specify options is useful when you want
to preconfigure and save your options for repeated use. The fields and values of
the options
structure correspond to names and values of
name-value pair arguments.
Examples
Input Arguments
Limitations
The
publish
function does not include formatted text when generating a view of a live script or function (.mlx
). To generate a view of the entire live script or live function, use theexport
function instead.Publishing a MATLAB code file (
.m
) by calling thepublish
function from a live script or function (.mlx
) is not supported.The
publish
function does not support theinput
function. Publishing a MATLAB code file (.m
) that contains a call to theinput
function results in an error.
Tips
To enhance the readability of the published document and include additional image snapshots, external file content, and external images, see Publishing Markup.
To avoid duplicate snapshots when publishing MATLAB code files, make sure that your cursor is not positioned over any figures before calling the
publish
function. Having the cursor on a figure can cause the figure to update and thepublish
function to generate duplicate snapshots.