REW

What Is MATLAB File Extension MLX?

Published Aug 29, 2025 4 min read
On this page

An .mlx file is a MATLAB Live Script, an interactive document that combines MATLAB code, formatted text, equations, and embedded outputs and visualizations into a single, cohesive file.

Unlike standard MATLAB scripts (.m files), which separate code from results in the Command Window, the Live Script format integrates everything within an interactive notebook-style environment called the Live Editor. This makes .mlx files a powerful tool for developing, documenting, and sharing your work.

The Live Editor experience

The Live Editor is the dedicated environment within MATLAB for creating and interacting with .mlx files. It features a WYSIWYG (what you see is what you get) interface that allows you to execute code and view the results and graphics in line with the code that produced them.

Key features of the Live Editor include:

  • Mixing code and text: Create an executable narrative by interweaving MATLAB code with richly formatted text, headings, and bulleted lists.
  • Embedded output: View plots, tables, and other outputs directly beneath the code that generated them.
  • Rich formatting: Use built-in tools to add headings, bold text, images, hyperlinks, and LaTeX equations to enhance your documentation.
  • Interactive controls: Insert sliders, dropdown lists, and other controls to dynamically change variables and explore the effects of different parameters on your code.
  • Code sections: Divide your script into logical sections that can be run and evaluated independently.

MLX vs. M-files: A detailed comparison

The primary differences between a MATLAB Live Script (.mlx) and a traditional MATLAB script (.m) lie in their formatting, output handling, and interactivity.

Feature MLX File (Live Script) M-File (Plain Script)
Storage format A binary file (using Open Packaging Conventions, like a .zip file) that stores code, formatted text, and output together. A plain text file that contains only MATLAB code and comments.
Output display Output and plots are displayed and saved directly within the document, next to the code that produced them. Output is displayed in the Command Window and is not saved within the .m file.
Text formatting Supports rich text formatting, headings, and embedded content directly in the Live Editor. Uses publishing markup within comments (%%) for formatting. The file must be "published" to see the formatted output.
Interactivity Supports interactive controls (sliders, drop-downs) and dynamic tasks that can be adjusted without rewriting code. Does not support interactive controls. Changes to parameters require editing the code directly.
Source control While binary .mlx files are difficult to track with standard source control (requiring MATLAB's comparison tool), a new plain-text .m format for live scripts (starting in R2025a) has been introduced to address this. Can be easily compared and merged with external source control tools like Git, as they are plain text.

The MLX file format structure

An .mlx file is not a simple plain text document. It is a binary file based on the Open Packaging Conventions (OPC), an extension of the .zip file format. This means that if you were to change the file extension from .mlx to .zip, you could actually open it and explore its contents. Inside, you would find an XML-based structure similar to Microsoft Office files, with separate components for the code, formatted text, and output.

Advantages of using MLX files

  • Enhanced readability: By combining code, results, and explanatory text in one document, Live Scripts make your work easier to understand and reproduce for yourself and others.
  • Effective for teaching and presentations: The interactive, narrative-style format is ideal for demonstrating concepts in a classroom or presenting analysis results in a meeting.
  • Interactive experimentation: The ability to add sliders and controls allows for rapid and visual exploration of how different parameters affect your results, without needing to change the code itself.
  • Simplified code development: Breakpoints, step-by-step debugging, and easy execution of code sections streamline the development process.
  • Integrated rich media: Embedded plots, images, and videos in the document help provide a complete picture of your analysis.

Sharing and converting MLX files

MLX files are natively opened and edited in MATLAB's Live Editor. To share them with someone who does not have MATLAB, or to use them in other contexts, you can export them to a variety of formats:

  • PDF: For a static, print-friendly version of the document.
  • HTML: For web-based viewing, preserving most formatting.
  • Microsoft Word: A editable document format.
  • LaTeX: For high-quality, typeset documents.
  • Markdown: A simplified markup language.
  • Traditional M-File (.m): This converts the script back to a plain .m file. The output will be lost, and formatted text will become standard comments.

The export process generates a static representation of your Live Script and its outputs at the time of export, allowing for broad sharing and distribution.

Enjoyed this article? Share it with a friend.