Main Content

Ways to Share and Export Live Scripts and Functions

R2026b

You can share live scripts and functions with others for teaching or demonstration purposes, or to provide readable, external documentation of your code.

This table shows the different ways to share live scripts and functions.

Ways to ShareInstructions
Share file directly.

Distribute the live code file. Recipients of the file can open and view it in MATLAB® in the same state that you last saved it, including any generated output.

If the file is saved using the plain text live code file format (.m), users can also open the file in any external text or code editor that supports plain text. For more information about the different live code file formats, see Live Code File Formats.

Export file to documents viewable outside of MATLAB.

Supported formats include:

  • PDF

  • Microsoft® Word

  • HTML

  • LaTeX

  • Markdown

  • Jupyter® notebooks

To export your live script or function interactively, on the Live Editor tab, select Export and then select a format. To export all of the live scripts and functions in a folder, on the Live Editor tab, select Export > Export Folder.

In the Export dialog box that opens, you can customize the export options. (since R2023b)

  • Change the paper size, orientation, and margins when exporting to PDF, Microsoft Word, and LaTeX.

  • Specify whether to include outputs when exporting to Markdown and Jupyter notebooks. (since R2024a)

  • Specify the location for saving generated media when exporting to HTML, LaTeX, Markdown, and Jupyter notebooks.

  • Change the resolution and format of figures when exporting to PDF, HTML, LaTeX, Markdown, and Jupyter notebooks (requires the files to be run before exporting).

For more information about the different export options, see the corresponding name-value arguments for the export function.

The converted file closely resembles the appearance of the live script or function with output inline. If the live script contains controls or tasks, MATLAB saves them as code in the converted file.

When exporting to LaTeX, MATLAB creates a separate matlab.sty file in the same folder as the converted file, if one does not exist already. STY files, also known as LaTeX Style documents, give you more control over the appearance of the converted files.

Alternatively, you can use the matlab.editor export settings to customize the converted file before exporting.

To export your live script or function programmatically, use the export function.

When using the export function, you can customize the converted file using name-value arguments. For example, you can hide the code in the converted file, specify the resolution and format of figures, and adjust the document paper size, orientation, and margins.

Show the files as a full-screen presentation.

Open the live script or function. Then, go to the View tab and click the Full Screen button on. Alternatively, you can use the Ctrl+F11 keyboard shortcut. On macOS, use the Command+F11 keyboard shortcut instead.

To exit full-screen mode, move the mouse to the top of the screen to display the View tab and click the Full Screen button off. You also can use the Exit fullscreen button at the top-right of the screen.

Hide Code Before Sharing

Before sharing or exporting your live scripts, consider hiding the code. When you hide the code, only output, labeled controls, tasks, and formatted text appear in the live script. If a task in the live script is configured to show only code and no controls, then the task does not display when you hide the code. Hiding the code is useful when sharing if you want others to change only the value of the controls in your live script or when you do not want others to see your code.

To hide the code, click the Hide code button to the right of the live script. You also can go to the View tab, and in the View section, click Hide Code . To show the code again, click the Output inline button or the Output on right button . Alternatively, if you are using the export function to share your live script, you can hide the code using the HideCode name-value argument.

Note

When exporting to PDF, Microsoft Word, HTML, LaTeX, Markdown, or Jupyter notebooks, MATLAB saves controls and tasks as code. If you have a live script that contains controls and tasks and you hide the code before exporting, the converted file does not contain the controls or tasks.

See Also

Functions

Settings

Topics