What Is a Live Script or Function?
MATLAB® live scripts and live functions are interactive documents that combine MATLAB code with formatted text, equations, and images in a single environment called the Live Editor. In addition, live scripts store and display output alongside the code that creates it.
Use live scripts and functions to:
Visually explore and analyze problems
Write, execute, and test code in a single interactive environment.
Run blocks of code individually or as a whole file, and view the results and graphics with the code that produced them.
Share richly formatted, executable narratives
Add titles, headings, and formatted text to describe a process and include equations, images, and hyperlinks as supporting material.
Save your narratives as richly formatted, executable documents and share them with colleagues or the MATLAB community, or convert them to HTML, PDF, Microsoft® Word, or LaTeX documents for publication.
Create interactive lectures for teaching
Combine code and results with formatted text and mathematical equations.
Create step-by-step lectures and evaluate them incrementally to illustrate a topic.
Modify code on the fly to answer questions or explore related topics.
Share lectures with students as interactive documents or in hard copy format, and distribute partially completed files as assignments.
Differences with Plain Code Scripts and Functions
Live scripts and live functions differ from plain code scripts and functions in several ways. This table summarizes the main differences.
|Live Scripts and Functions||Plain Code Scripts and Functions|
|File Format||Live Code file format. For more information, see Live Code File Format (.mlx)||Plain Text file format|
|Output Display||With code in the Live Editor (live scripts only)||In Command Window|
|Text Formatting||Add and view formatted text in the Live Editor||Use publishing markup to add formatted text, publish to view|
MATLAB R2016a — MATLAB supports live scripts in versions R2016a and above, and live functions in versions R2018a and above.
Operating System — Starting in R2019b, MATLAB supports the Live Editor in all operating systems supported by MATLAB. For more information, see System Requirements.
For MATLAB versions R2016a through R2019a, the Live Editor is not supported in several operating systems supported by MATLAB.
Unsupported operating systems include:
Red Hat Enterprise Linux 6.
Red Hat Enterprise Linux 7.
SUSE Linux Enterprise Desktop versions 13.0 and earlier.
Debian 7.6 and earlier.
In addition, some operating systems require additional configuration to run the Live Editor in MATLAB versions R2016a through R2019a. If you are unable to run the Live Editor on your system, Contact Technical Support for information on how to configure your system.
Some MATLAB features are unsupported in the Live Editor:
Classes — Classes are not supported in the Live Editor. Create classes as plain code files (
.m) instead. You then can use the classes in your live scripts or functions.
MATLAB preferences — The Live Editor ignores some MATLAB preferences, including custom keyboard shortcuts and Emacs-style keyboard shortcuts.