Main Content

Steps for Deployment with MATLAB Compiler

Use MATLAB® Compiler™ and MATLAB Compiler SDK™ to package MATLAB files into deployable components that do not require MATLAB to run.

With MATLAB Compiler, you can create standalone applications, web apps, Microsoft® Excel® Add-ins, and MapReduce or Spark™ big data applications.

With MATLAB Compiler SDK, you can create C/C++ shared libraries, .NET assemblies, Java® classes, Python® packages, COM components, MATLAB Production Server™ deployable archives, Excel add-ins for MATLAB Production Server, and Docker® container-based microservices.

Write Deployable MATLAB Code

To package MATLAB scripts, functions, or class files, you must ensure the code is in a finished state and ready to be run by the end user. You can use functions such as isdeployed to separate code that runs before deployment. For more information, see Write Deployable MATLAB Code.

In addition to MATLAB scripts, MEX files, and class files, you can include other types of files, such as data files, in a compiled artifact. For details, see Access Files in Packaged Applications

Package Code for Target

You can use the following options to package MATLAB code.

  • The and compiler.package functions, which allow you to package MATLAB code at the command line

  • The deploytool compiler apps, which allow you to package MATLAB code using a graphical interface

  • The mcc function, which allows you to package MATLAB code at the command line and offers additional options to control the packaging process

During the packaging process, the compiler uses a dependency analysis function to include necessary supporting files. For more information, see Dependency Analysis Using MATLAB Compiler.

Distribute Files to Target Platform

Once you create a component, distribute either the application files or an installer that contains all of the resources required to run the application on the target platform. You can create an installer using a deploytool app or using the compiler.package.installer function. For more information on distributing files, see Distribute Files to Application Developers.

If you execute an installer containing the compiled artifacts, then MATLAB Runtime is installed along with the application or shared library. If you distribute files manually, ensure MATLAB Runtime is accessible from the target machine.

Install MATLAB Runtime

MATLAB Runtime is a freely available set of shared libraries that enables you to run packaged MATLAB code without needing a licensed version of MATLAB. The version and update level of MATLAB Runtime must be the same or newer than the version of MATLAB used to compile the component.

For information on installing MATLAB Runtime, see Install and Configure MATLAB Runtime.

You can run your deployed component on your development machine in MATLAB without needing MATLAB Runtime.

Integrate Artifact with Application in Target Language

For some targets, such as .NET or Java, the compiler invokes the corresponding third-party compiler to create the artifact, so you must set up your development environment to work with the target language. For details, see the MATLAB Compiler SDK documentation for the target language.

To integrate a compiled artifact with an application in the target language, write code that calls the packaged MATLAB functions. MATLAB Compiler SDK can generate sample code for C++, .NET, Java, and Python that demonstrates how to call your exported MATLAB function in the target language. You can use samples to implement your own application or to test the compiled artifact. For more details, see Create Sample Code to Call Exported Function (MATLAB Compiler SDK).

Limitations and Restrictions

You can package most MATLAB functionality that can be called directly from the command line. For a list of functions not supported by MATLAB Compiler, see Functions Not Supported for Compilation by MATLAB Compiler and MATLAB Compiler SDK.

Compiled applications can run only on the same platform on which they were developed, with a few exceptions. For more details, see Limitations (MATLAB Compiler SDK).

See Also

| | |

Related Topics