Main Content

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 (live scripts only) or as a whole file, and view the results and graphics with the code that produced them.

Live script with two outputs. Each output is displayed to the right of the code that produced it.

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 files, PDF files, Microsoft® Word documents, LaTeX files, Markdown files, and Jupyter® notebooks for publication.

Live script with a heading, image, descriptive text with formatted equations, and code

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.

Live script containing a homework assignment with three exercises and text inviting the user to complete the exercises by adding code and text directly to the live script

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 FunctionsPlain Code Scripts and Functions
File FormatLive Code file format. For more information, see Live Code File Format (.mlx)Plain Text file format
File Extension.mlx.m
Output DisplayWith code in the Live Editor (live scripts only)In Command Window
Text FormattingAdd and view formatted text in the Live EditorUse publishing markup to add formatted text, publish to view
Visual Representation

Live script with code, output, and formatted text

Plain code script showing code and green commented text

Requirements

  • 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.

Unsupported Features

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.

Related Topics