Interactively Create and Share Packages
R2026bBundle MATLAB® files to create a package to share with others. These files can include
MATLAB code, data, apps, examples, and documentation. When you create a package,
MATLAB generates a single installation file (.mltbx) that enables
you or others to install your package.
When developing code in MATLAB, consider using projects to help organize code and track dependencies. For more information on using projects and other development tools to publish a package, see Develop and Share Software in MATLAB.
Create Package
Starting in R2025a, package building is integrated with projects. To create a package from your files, create a package task within a project. Then, use the package task to configure and build your package.
Before R2025a: To create your package, go to the
Home tab, and in the Environment section, select Add-Ons > Package Toolbox. Then, in the Package a Toolbox dialog box, click the
button and select your package folder. Configure your
package and then click Package to create your package installation
file.
Create Package Task
The first step to creating a package is to create a package task. You can then use the package task to configure and build your package.
There are two ways to create a package task:
If the files you want to package are already included in a project, open the project, go to the Project tab, and in the Tools section, click Build Package. MATLAB creates a package task with the same name as your project and opens it in the document area of the desktop.
If your files are not already included in a project, go to the Home tab, and in the Environment section, select Add-Ons > Build Package. Click Browse to select the folder containing the files you want to package, and click OK. MATLAB creates a new project containing your files and a package task for configuring your package. If the folder you select already contains a project, the existing project is used instead.
When creating a project for your package, you can choose the project metadata format.
Starting in R2026b, you can select the MATLAB Projects TOML Format (.toml) as the definition
file type of your project. To change the default metadata format, on the
Home tab, in the Environment section, click
Settings. Select MATLAB > Project, and in the New Projects section, set
Project definition files to matlab.toml.
The TOML format is recommended over the default multi-file format and has the following
benefits when used with packages:
Single user-readable file for managing all project and package metadata
Path management and enforced environmental consistency
Dependency management with packages outside of the project
Improved integration with source control
To reopen the package task after closing it, go to the Project tab and click Build Package. You also can click Compiler Task Manager to view all the package tasks in the project.
Specify Package Folder
The Package Folder section shows the package folder and a preview of the files in the package. To add or change the package folder, click the Select Folder button.
By default, MATLAB excludes source control and project resource files from the package. In
addition, if your package contains a P-code file and a MATLAB code file (.m) with the same name in the same folder,
MATLAB excludes the .m file from the package. To show the
excluded files in the preview, click the Toggle Display of
Exclusions button. To exclude other files or folders from the package, click
the Edit Exclusions button and add them to the text file that opens.
A best practice is to exclude any source control files related to your package.
Specify Package Information
In the Package Information section, specify information about your package, as described in the table.
If your package folder contains a package definition file, MATLAB uses the package information, such as the description, summary, and package name, to automatically prepopulate some of the package information fields when creating the package task. You can then further edit these fields. For more information about packages, see Programmatically Turn Your Code Into a Package.
| Package Information Field | Description |
|---|---|
| Display name | Enter the display name, if necessary. By default, the display name is the name of the package folder. |
| Package name | Enter the package name. The package name must be a valid MATLAB identifier. By default, the package name is the name of the package folder with invalid characters removed. |
| Version | Enter the package version number. Version syntax follows
the Semantic Versioning 2.0.0
format:
|
| Author name, Email, and Company | Enter the contact information for the package author. |
| Package image | Point to the image at the top-left corner of the section and click Browse to select an image that represents your package. The image must be in the project folder. |
| Summary and Description | Enter the package summary and description. A best practice is to keep the Summary text brief and to add detail to the Description text. When you build your package if no readme file is included with
in the package folder then the content of the description field is used to
generate a readme file and this file is added to the |
Review Package Requirements
MATLAB automatically analyzes your package files and detects requirements to include with your package. The Package Requirements section shows these requirements. To ensure your package includes all required files, review the detected requirements as described in the table and resolve warnings, if necessary.
| Package Requirements Field | Description |
|---|---|
| Required Packages | Specify the list of packages that your package depends on. Specified dependencies are downloaded and installed when the package is installed. MATLAB automatically populates this list with the packages it determines the package depends on and specifies them all by default. You can choose to omit any dependencies you do not want to install with your package. If MATLAB is unable to find the installation information for a depenedency in the list, you must enter a download URL. The download URL is the location where MATLAB can download and install the dependency. When the package is installed, MATLAB also installs the dependencies using the specified URLs. |
| Discovered Requirements | Specify the list of files required for your package that are located outside the package folder. MATLAB automatically populates this list with the files it determines the package requires and specifies them all by default. You can choose to omit any files you do not want in your package. Click the View Analysis button to view the analysis in the Dependency Analyzer. To rerun the analysis, click the Reanalyze button. |
Specify Output Settings
The Output Settings section shows the filename and path for your
package file (.mltbx). By default, the output filename is the package
name and the path to the file is the release folder in the project root
folder.
To change the filename and path for your package installation file, enter a new
filename with a .mltbx extension and click
Browse to select a different output path.
Add Install Actions (Optional)
The Install Actions section shows the additional actions that occur when your package is installed, including setting the MATLAB path and the Java classpath, installing apps, and opening the Getting Started guide. You can configure the install actions, as described in the table.
| Install Actions Field | Description |
|---|---|
| MATLAB Path | Specify the list of folders that are added to the user’s MATLAB path when the user installs the package. By default, the list includes any of the package folders that are on your project path. You can exclude folders from being added to the user’s path by clearing them from the list. To manage the path for package installation, click Manage Project Path. To reset the list to the default list, click Restore Default Path. |
| Java Classpath | Specify the list of Java® files that are added to the user’s Java classpath when the user installs the package. Upon package installation, the JAR files are added to the dynamic path for the duration of the MATLAB session. When the package user restarts MATLAB, the JAR files are added to the static path. |
| Apps | Specify the published MATLAB installable apps associated with your package.
|
| Getting Started Guide | Specify a Getting Started guide for your package. For the package task
to recognize a Getting Started guide, include the guide as a live script named
Users of your package can view the Getting Started guide through the Options menu for the package in the Add-Ons panel. For more information, see Get and Manage Add-Ons. |
Configure Package Portability
MATLAB uses the information in the Package Portability section when the user installs the package. If the compatibility check fails because the user has an unsupported platform or MATLAB release, MATLAB displays a warning. However, the user still can install the package.
| Package Portability Field | Description |
|---|---|
| Supported Platforms | Specify the platforms that support the package. Consider if your package has third-party software or hardware requirements that are platform specific. MATLAB Online™ cannot interact with hardware, including devices used for image acquisition and instrument control. |
| Release Compatibility | Specify the MATLAB releases that support the package. |
Add Third-Party Software (Optional)
The Third-Party Software section lists additional third-party software ZIP files that are installed on the user's system when the user installs the package. To add additional third-party software to install with your package, click the Add button and specify these fields:
Software Name — The name to display to the user during installation.
Platform — The platform that the additional software runs on.
Download URL — The URL to the ZIP file that contains the additional software. To specify different download URLs for different platforms, add separate entries for each platform.
License URL — The URL of the additional software license agreement to display to the user during installation. The user is prompted to review and agree to the license agreement during installation. You must specify a valid URL to the license agreement.
When the user installs a package, MATLAB installs all additional third-party software in the
folder, where addons\Toolboxes\AdditionalSoftwareaddons is the default add-ons installation
folder. For more information about the location of the default add-ons installation
folder, see Get and Manage Add-Ons.
If your package contains code that refers to the installation folder of the specified
additional third-party software, make these references portable to other computers.
Replace the references with calls to the generated function
,
where packagename\getInstallationLocation.mlxpackagename is the name of your package. For example, if
you are creating a package named mypackage and want to reference the
install location for additional software named mysoftware, replace this
code
mysoftwarelocation = 'C:\InstalledSoftware\mysoftware\'
mysoftwarelocation = mypackage.getInstallationLocation('mysoftware')Build Package
After configuring your package, follow these steps to create a package installation
file (.mltbx):
Click the Reanalyze button at the top of the package task to check your package for issues. Resolve any errors before proceeding.
Click the Build Package button at the top-right corner of the package task to create your package installation file (
.mltbx). MATLAB creates the file in the folder specified in the Output Settings section.
Share Package
To share your package with others, distribute the package installation file
(.mltbx) to them. All files you added when you built the package are
included in the file. When end users install your package, MATLAB Package Manager manages their MATLAB path and other installation details.
You can share your package with others by attaching the package installation file to an email message or using any other method you typically use to share files, such as uploading to MathWorks File Exchange. If you upload your package to File Exchange, your users can search for and download the package from within MATLAB by using the Add-Ons panel. For more information on installing, uninstalling, and viewing information about a package, see Get and Manage Add-Ons.
Note
Although package installation files can contain any files you specify, File Exchange places additional limitations on submissions. Data and image files are typically acceptable. However, you cannot submit your package to File Exchange if it contains any of these types of files:
MEX files
Other binary executable files, such as DLL files or ActiveX® controls
Upgrade Package Created in Previous Release
If you have a package created in a release before R2025a as well as its associated
.prj file, MATLAB can automatically upgrade your package to the project workflow.
To upgrade your package, open the .prj file by double-clicking it in
the Files panel. MATLAB automatically creates a project and adds your package files and information to
a new package task. Verify the package information and then build your package using the
steps in Build Package.