Share Live Scripts and Functions
You can share live scripts and live functions with others for teaching or demonstration purposes, or to provide readable, external documentation of your code. You can share the files as an interactive document with other MATLAB® users, or you can share static PDF, Microsoft® Word, HTML, and LaTeX versions of the files for viewing outside of MATLAB.
This table shows the different ways to share live scripts and functions.
|Ways to Share||Instructions|
|As an interactive document|
Distribute the live code file (
MATLAB supports live scripts starting in R2016a and live functions starting in R2018a.
|As a static document viewable outside of MATLAB|
Export the live script or function to a standard format. Available formats include PDF, Microsoft Word, HTML, and LaTeX.
To export your live script or function to one of these formats, on the Live Editor tab, select Export and then select a format. The saved file closely resembles the appearance of the live script or function when viewed in the Live Editor with output inline. To export all of the live scripts and live functions in a folder, on the Live Editor tab, select Export > Export Folder. In MATLAB Online™, go to the Live Editor tab and select Save instead of Export.
When exporting to
LaTeX, MATLAB creates a separate
Alternatively, to export your live script or
function programmatically, use the
You also can use settings to customize the converted file before exporting. For more information, see matlab.editor Settings.
|As a full-screen presentation|
Open the live script or function, go to the View tab and click the Full Screen button. MATLAB opens the file in full-screen mode.
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 again.
|As a MATLAB code file|
Save the live script or function as a plain code file
For more information, see Save Live Scripts as Plain Code.
Hide Code Before Sharing
Consider hiding the code in the live script before sharing it as an interactive or static document. When the code is hidden, the Live Editor displays only formatted text, labeled controls, Live Editor tasks, and output. If a Live Editor task is configured to only show code and no controls, then the task does not display when you hide 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
export | matlab.editor Settings