Publishing MATLAB Code from The Editor
This demonstration shows you how to publish your MATLAB code from the editor to HTML and other formats, useful if we need to share or describe your work to others. Let's first open an example script that creates and filters some signals. To publish MATLAB code, you must first divide it into sections by inserting section breaks with double percent. You can also press the tool strip button to add sections.
With your code divided into sections, you can iterate on one section at a time. You can also execute one section and advance to the next. To publish your MATLAB code using the default options, press the Publish button here. Your code then executes. And the graphical or textual results generated for each cell are captured and published to HTML, which is the default document type.
You can add more descriptive text and formatting to the output document. We will look at another version of this MATLAB file which has been added. You add a title by including a cell at the top without any code. You can add a description here or in any section. And the comments will be turned into body text in the output document.
You can give that cell names, which will be turned into section headings. You can format your document text by inserting special markup text. For example, you can write an equation using standard LaTeX markup.
You can specify bullets. Note that you can add comments in a cell without a header for additional body text. You can specify basic font formatting such as mono-spaced or bold.
The command when to output will also be captured, such as when this variable, b, is displayed. All markup can be inserted via the Context menu or via the toolstrip buttons, such as here, we will insert a hypertext link.
We will publish it again. Here you see the document title and the comments that have been turned into body text. Here is the equation.
Cell names have been turned into section headings, and a table of contents, created. There is the ability list, the mono-spaced text, and the bold text, and the command window output. You can specify different publishing settings for different files and also publish MATLAB code that is contained in a function file requiring input arguments by using published configurations.
Here I have some code in a MATLAB function which reads some data from a file that varies as a function of time and puts the information for one particular date that you specify as an input argument, such as-- you make a customized published configuration associated just with this file by clicking here. You can specify some code to run, particularly useful when calling a function with input arguments. You can specify different output formats, such as LaTeX, Word, PowerPoint. Here we will choose Word.
And you can specify whether or not to include the code or evaluate the code. You can save these settings and reuse them for other configurations. Then we will close this and publish again using the new settings.
Here we see the document is generated in the format we specified. Just like with scripts, when publishing functions, you can include a title by inserting an additional cell at the top. Here we see the title. You can create multiple configurations for the same file by clicking here and specifying additional options or a code. And that, we access from here.
Finally, you can also create documents from the command line with the publish function. This concludes the demonstration. You can try these examples in MATLAB now or watch one of the other videos.
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.