Main Content

MATLAB Coder

Generate C code or MEX function from MATLAB code

Description

The MATLAB Coder app generates C and C++ code from MATLAB® code as standalone static libraries, dynamically linked libraries, or executables. The generated code can be embedded in applications outside the MATLAB environment. The MATLAB Coder™ app also generates C/C++ MATLAB executable (MEX) functions designed for MATLAB acceleration. The MATLAB Coder app is integrated into the MATLAB desktop and is available in MATLAB Online™.

The user interface includes:

  • The MATLAB Coder tab on the toolstrip, where you can configure code generation settings, control the language and build type of the generated code, open the Entry Points pane, generate code, and perform code verification.

  • The Entry Points pane, where you can add entry-point functions and global variables. You can also define input types automatically or manually.

  • The MATLAB Coder panel, which suggests next steps. In this panel, the Input section summarizes entry points and global variable inputs, and the Output section summarizes the output. After you generate code, this section provides quick access to the generated code.

Using the app, you can:

  • Generate code in MATLAB Online.

  • Create a project or open an existing project. The project specifies the input files, entry-point function input types, and build configuration.

  • Review code generation readiness issues, including unsupported functions.

  • Check the generated MEX function for run-time issues.

  • Switch between the MATLAB editor and the code generation Entry Points pane.

  • Verify the numerical behavior of generated code using software-in-the-loop and processor-in-the-loop execution (requires Embedded Coder®).

  • Export project settings in the form of a MATLAB script.

  • Access generated files.

  • Package generated files as a single zip file for deployment outside of MATLAB.

When the app creates a project, the app enables Embedded Coder features if the Embedded Coder product is installed. When Embedded Coder features are enabled, code generation requires an Embedded Coder license. To disable Embedded Coder features, open the MEX Code Generation Settings or Standalone Code Generation Settings dialog box. On the Advanced pane, clear the Use Embedded Coder features check box.

MATLAB Coder app

Open the MATLAB Coder App

  • MATLAB Toolstrip: On the Apps tab, under Code Generation, click the app icon.

  • MATLAB command prompt: Enter matlabcoder.

Programmatic Use

Version History

Introduced in R2015a

expand all

See Also

Functions