MATLAB Coder

Generate C code or MEX function from MATLAB code

Description

The MATLAB Coder app generates C or C++ code from MATLAB® code. You can generate:

  • C or C++ source code, static libraries, dynamically linked libraries, and executables that you can integrate into existing C or C++ applications outside of MATLAB.

  • MEX functions for accelerated versions of your MATLAB functions.

The workflow-based user interface steps you through the code generation process. Using the app, you can:

  • 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 your MATLAB function for run-time issues.

  • Fix issues in your MATLAB code using the integrated editor.

  • Convert floating-point MATLAB code to fixed-point C code (requires a Fixed-Point Designer™ license).

  • Convert double-precision MATLAB code to single-precision C code (requires a Fixed-Point Designer license).

  • Trace from MATLAB code to generated C or C++ source code through comments.

  • See static code metrics (requires an Embedded Coder® license).

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

  • 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, if the Embedded Coder product is installed, the app enables Embedded Coder features. When Embedded Coder features are enabled, code generation requires an Embedded Coder license. To disable Embedded Coder features, in the project build settings, on the All Settings tab, under Advanced, set Use Embedded Coder features to No.

The MATLAB Coder app is not supported in MATLAB Online™.

Open the MATLAB Coder App

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

  • MATLAB command prompt: Enter coder.

Programmatic Use

See Also

Apps

Functions