主要内容

App Designer File Formats

R2026b

App Designer has two file formats for storing apps. You can choose the format that best fits how you edit and manage your apps.

  • Binary format (.mlapp) — By default, App Designer saves apps in a binary format.

  • Plain text format (.m and .xml) — You can also save apps in a plain text format. This format is useful for apps that you manage with source control or that you want to edit outside of App Designer. (since R2026b)

Choose App File Format

Apps saved in the binary format and the plain text format have the same behavior in App Designer. Choose the file format based on how you plan to develop and share your app outside of App Designer. This table summarizes the main considerations for choosing a file format for your app.

If your app is complex and contains many components, converting your app to the plain text format might improve startup performance.

ConsiderationsBinary FormatPlain Text Format (since R2026b)
File extensions.mlapp

Plain text apps consist of two files:

  • .m (app code file)

  • .xml (app configuration file)

Supported editors

  • App Designer

  • App Designer

  • MATLAB Editor

  • External editors

Source control support

  • MATLAB® Comparison Tool

  • MATLAB Comparison Tool

  • External source control tools

Limitations

Not compatible with:

  • External editors

  • External source control tools

Does not support:

  • Creating apps for Simulink® models

  • Creating custom UI components

Apps in Binary Format

The default app file format consists of one file with an .mlapp extension. This app format uses Open Packaging Conventions (OPC) technology, which is based on the ZIP file format.

Because of the binary file format, you can edit apps with an .mlapp extension only in App Designer. To compare and merge different versions of an app in the binary format, use the MATLAB Comparison Tool instead of external source control tools. For more information, see Compare and Merge Apps.

Apps in Plain Text Format

The plain text app file format consists of two files:

  • A MATLAB code file (.m) that contains all of the app code you write, such as callbacks and properties

  • An XML file (.xml) that contains the app configuration, including the app components, layout, and metadata

The code file contains a property, AppConfigFilename, that stores the path to the app configuration file. By default, the .m and .xml files have the same name and are saved to the same folder.

This table describes how app components and functions are referenced in each file.

ReferenceApp Code File (.m)App Configuration File (.xml)
Components

App property with a name that matches an element in the configuration file

properties (Access = public)
     myButton matlab.ui.control.Button
end

Element with a name attribute that matches a property in the code file

<Button name='myButton'>
    <!-- ... -->
</Button>

Callback functions

App function in methods block, managed by App Designer

function myButtonPushed(app,event)
     % ...
end    

In a component block, a callback element that matches a callback function in the code file

<Button name='myButton'>
    <ButtonPushedFcn>myButtonPushed</ButtonPushedFcn>
    <!-- ... -->
</Button>

Startup function

App function in methods block, managed by App Designer

function startupFcn(app)
     % ...
end   

Element in the RunConfiguration block

<RunConfiguration>
    <StartupFcn>startupFcn</StartupFcn>
</RunConfiguration>

App Designer is the recommended environment for editing plain text apps. When you open a plain text app in App Designer, you edit the app code file in Code View. App Designer automatically updates the app configuration file when you make changes to the components, layouts, and other metadata in Design View.

You can also open the app code and app configuration files in other editors. For example, to open a file in the MATLAB Editor, right-click the file in the Files panel and select Open as Text.

You can use other editors for these tasks:

  • Viewing the app code outside of App Designer

  • Adding code to sections of the file that you can edit in App Designer Code View

However, using other editors for the following tasks might cause App Designer to remove incompatible code when you load the app:

  • Making changes to the app layout

  • Adding a new callback function

  • Adding a new property to the UI components block

One major benefit of using the plain text app format is improved integration with source control. In addition to using the MATLAB Comparison Tool, you can use external source control tools to compare and merge different versions of an app in the plain text format. For more information, see Source Control Integration in MATLAB.

Set Default App File Format

By default, apps created in App Designer use the .mlapp extension. To change the default app file format, follow these steps:

  1. In MATLAB, on the Home tab, in the Environment section, click Settings.

  2. Select App Designer in the left panel.

  3. Under File Format, set Create new apps as to either M or MLAPP.

Convert Between App File Formats

To convert an existing app to a different file format, create a copy and select either MATLAB App (*.m) or MATLAB App (*.mlapp) in the file browser that appears when you save the copy.

App Designer provides two options to create copies of your app: Save As and Save Copy As. You can access both options from the Save button in the App Designer toolstrip. These options serve different purposes and behave differently.

  • To save a copy of your app and continue editing it, use Save As. When you use this option, App Designer saves the copy of the app in the specified folder and replaces the app in your current session.

  • To save a copy of your app to edit or share later, use Save Copy As. When you use this option, App Designer saves the copy of the app in the specified folder, but it does not replace the app in your current session.

If you save a copy of your app in a different file format, rename your app or save it in a different folder. Otherwise, MATLAB might run an unintended version of the app.

See Also

Topics