
publish
Description
example
generates a view of the specified MATLAB® code file and output in an HTML format that can be used for sharing. saves the HTML file and a file for each graphic that the code creates in a subfolder named . The location of the subfolder is relative to the location of .
For example, runs the code in using the base workspace, and then saves the formatted code and results in .
example
generates a view of the specified MATLAB file in the specified file format. All file formats save to the subfolder.
example
generates a view of the specified MATLAB file with options specified by one or more pair arguments.
example
uses the 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 structure correspond to names and values of name-value pair arguments.
example
generates a view of the specified MATLAB file and returns the path of the resulting output file. You can use this syntax with any of the input argument combinations in the previous syntaxes.
Examples
collapse all
Generate HTML View of MATLAB Script
Generate an HTML view of a MATLAB script including the code, results, and comments.
Copy the example file to your current folder.
Use the function to run the example and generate an HTML view of the example. Then, use the function to view the resulting file.
Generate View of MATLAB Script in Microsoft Word Format
Generate a Microsoft® Word view of a MATLAB script including the code, results, and comments.
Copy the example file to your current folder.
Use the function to generate a Microsoft Word view of the example. Then, use the function to view the resulting file.
Customize View Using Name-Value Pairs
Use name-value pair arguments to change the appearance of published figure windows in the HTML view of a MATLAB script.
Copy the example file to your current folder.
Use the function to generate an HTML view of the example. Specify as to include window decorations and to match the figure background color to the screen color for figures. Then, use the function to view the resulting file.
Customize View Using Structure
Use a structure to create a Microsoft Word view of a MATLAB script that does not show the code from the script. Specifying options as a structure is useful when you want to preconfigure and save your options for repeated use.
Copy the example file to your current folder.
Create a structure that specifies the and options.
Use the function to generate a Microsoft Word view of the example using the options specified in . Then, use the function to view the resulting file.
Save File Path of Published Script to Variable
Generate an HTML view of a MATLAB script, and save the path of the published HTML file to a variable.
Copy the example file to your current folder.
Use the function to generate an HTML view of the example, and save the path of the published HTML file to the variable .
Input Arguments
collapse all
MATLAB file name
character vector | string
MATLAB file name, specified as a character vector or string. can include a full or partial path.
Note
When MATLAB publishes a file, it can overwrite existing files from the output folder that start with the same name as .
Example:
Example:
Output format
(default) | | | | |
Output format of published file, specified as one of the values listed in the table.
Value | Output Format |
---|---|
(default) | Hypertext Markup Language |
Microsoft Word | |
LaTeX | |
Microsoft PowerPoint® | |
Extensible Markup Language | |
Portable Document Format (PDF) |
The Microsoft Word and Microsoft PowerPoint formats are only available on Windows® platforms.
MATLAB does not preserve syntax highlighting when you specify the output format as Microsoft PowerPoint or LaTeX.
Example:
Options for published output
structure
Options for published output, specified as a structure. Use the structure instead of name-value pair arguments when you want to reuse the same configuration for publishing multiple MATLAB files.
The fields and values of the structure correspond to names and values of the name-value pair arguments.
For example, this command creates the structure , and specifies the PDF output format and the output folder .
Name-Value Pair Arguments
Specify optional comma-separated pairs of arguments. is the argument name and is the corresponding value. must appear inside quotes. You can specify several name and value pair arguments in any order as .
Example: specifies the PDF output file format and excludes the code from the output.collapse all
Output format
(default) | | | | |
Output format of published file, specified as one of the values listed in the table.
Value | Output Format |
---|---|
(default) | Hypertext Markup Language (HTML) |
Microsoft Word | |
LaTeX | |
Microsoft PowerPoint | |
Extensible Markup Language | |
Portable Document Format (PDF) |
The Microsoft Word and Microsoft PowerPoint formats are only available on Windows platforms.
MATLAB does not preserve syntax highlighting when you specify the output format as Microsoft PowerPoint or LaTeX.
Output folder
character vector
Output folder to which the published document is saved, specified as a character vector. Specify the full path of the folder.
Example:
Extensible Stylesheet Language (XSL) file
character vector
Extensible Stylesheet Language (XSL) file to use when publishing a MATLAB file to HTML, XML, or LaTeX format, specified as a character vector. Specify the full path of the XSL file.
Example:
collapse all
Whether to create thumbnail image
(default) |
Whether to create a thumbnail image for the published document, specified as or . You can use the generated thumbnail to display a small representation of your file on HTML pages.
Figure window appearance
(default) | | |
Figure window appearance for the published document, specified as one of the values listed in the table. Figure window appearance includes the background color of the plot and whether it includes window decorations (title bar, toolbar, menu bar, and window border).
This option is not available in MATLAB Online.
Value | Window Decorations | Background Color | ||
---|---|---|---|---|
GUIs | Figures | GUIs | Figures | |
(default) | Included | Excluded | Matches screen | White |
Excluded | Excluded | White | White | |
Excluded | Excluded | Matches screen | Matches screen | |
Included | Included | Matches screen | Matches screen |
Image file format
| | |
Image file format for the images in the published document, specified as one of the values listed in the table. The list of valid image formats depends on the specified output format.
Output Format | Valid Image Formats | Default Image Format |
---|---|---|
Microsoft Word | Any image format that your installed version of Microsoft Office can import, including , , , and . If the option is set to , then you also can specify , , , , , and . | |
Hypertext Markup Language (HTML) | All image formats. Ensure that the tools you use to view and process the output files can display the output format you specify. | |
LaTeX | All image formats. Ensure that the tools you use to view and process the output files can display the output format you specify. | The default changes to in these cases:
|
Portable Document Format (PDF) | and . | |
Microsoft PowerPoint | Any format that your installed version of Microsoft Office can import, including , , , and . | |
Extensible Markup Language (XML) | All image formats. Ensure that the tools you use to view and process the output files can display the image format you specify. |
Maximum image height
(default) | positive integer
Maximum image height of the published images, specified as one of these values:
(default) Unrestricted height. This value is always used when the output format is PDF.
Positive integer Height in pixels.
Maximum image width
(default) | positive integer
Maximum image width of the published images, specified as one of these values:
(default) Unrestricted width. This value is always used when the output format is PDF.
Positive integer Width in pixels.
Whether to create new figure
(default) |
Whether to create new figure, specified as or . If and the code generates a figure, then MATLAB creates a new figure window in the default size with a white background before publishing. If , MATLAB does not create a figure window.
Specifying a value of is useful if you want to use a figure with different properties for publishing. For example, you can open a figure window, change the size and background color, and then publish your code. Figures in your published document use the characteristics of the figure you opened before publishing.
collapse all
Whether to run code
(default) |
Whether to run the code and include the MATLAB output in the published view, specified as or .
Whether to catch errors
(default) |
Whether to catch errors during publishing, specified as or . If and an error occurs, MATLAB continues publishing and includes the error in the published file. If and an error occurs, MATLAB displays the error at the command line and does not produce a published file.
Additional code to run
character vector
Additional code to run during publishing, specified as a character vector. Use this option to run code that is not included in the MATLAB file. For example, you can set the value of an input argument for a function being published.
If this option is unspecified, MATLAB only runs the code in the MATLAB file you are publishing.
Maximum number of lines
(default) | nonnegative integer value
Maximum number of lines of output to be included in the published document, specified as one of these values:
(default) MATLAB includes all output in the published document.
Nonnegative integer MATLAB only includes the specified number of lines in the published document. Setting this option is useful if a smaller, representative sample of the output suffices.
Whether to include code
(default) |
Whether to include code in published file, specified as or .
If the output format is HTML, MATLAB includes the code at the end of the published HTML file as comments, even when you set the option to . Including the code as comments enables the function to extract the MATLAB code from an HTML file, even when the file does not display the code. The code does not display in a Web browser because MATLAB includes the code as comments.
Limitations
In MATLAB Online, you cannot use the function on a file in your folder. To publish a shared file, open the file in the Editor, and then click Publish on the toolbar. When you use the Publish button in MATLAB Online instead of the function, MATLAB stores the results in the subfolder of your root folder instead of the subfolder.
Tips
To enhance the readability of the published document and include additional image snapshots, external file content, and external images, see Publishing Markup.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
Select web siteYou can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office
0 thoughts to “How to download pdf from online matlab”