Generate C and C++ code from MATLAB code


MATLAB Coder™ generates C and C++ code from MATLAB® code for a variety of hardware platforms, from desktop systems to embedded hardware. It supports most of the MATLAB language and a wide range of toolboxes. You can integrate the generated code into your projects as source code, static libraries, or dynamic libraries. The generated code is readable and portable. You can incorporate your existing C code and libraries to get the ultimate efficiency for the key parts of your algorithm, or to reuse code you trust. You can also package the generated code as a MEX-function for use in the MATLAB environment for verification or acceleration.

Embedded Coder® enhances MATLAB Coder for production use with support for code customization, target-specific optimizations, code traceability, and software-in-the-loop (SIL) and processor-in-the-loop (PIL) verification.

To deploy MATLAB programs as standalone applications, use MATLAB Compiler™ and to generate software components for integration with other programming languages, use MATLAB Compiler SDK™


Run Anywhere

Generate readable and portable ANSI C source code. Deploy code royalty-free.

Deploy Algorithms Royalty-Free

Use any C compiler to compile and run your generated code on any hardware, from desktop systems to mobile devices to embedded hardware. The generated code is royalty-free—deploy it in commercial applications to your customers at no charge.

Generated code for matrix multiply.

dorsaVi medical/sports motion analysis algorithms.

Supported Toolboxes and Functions

MATLAB Coder generates code from a broad range of MATLAB language features that design engineers use to develop algorithms as components of larger systems. This includes over 1900 operators and functions from MATLAB and companion toolboxes.

MATLAB language and toolbox support for code generation.

Prototype on Hardware

Get to hardware fast with automatic conversion of your algorithm to C.

Prototype on Desktop and Cloud Platforms

Use the MATLAB Coder app or equivalent command-line functions to quickly generate code for your signal processing, computer vision, deep learning, control systems, or other application and then compile the code for your hardware.

Prototyping algorithms quickly on desktop and cloud platforms.

Prototype on Embedded and Mobile Platforms

Target any device by manually integrating the generated code with your application. Automate the process for Raspberry Pi™ using MATLAB Support Package for Raspberry Pi.

Prototyping algorithms quickly on embedded and mobile platforms.

Move from Prototyping to Production

Use MATLAB Coder with Embedded Coder® to generate code that takes advantage of processor-specific intrinsics that can execute faster than standard ANSI/ISO C/C++ code.

Profile execution time of the generated standalone code.

Integrate with Software

Reuse MATLAB algorithms as C code within your software environment.

Generate Code with Simple Interfaces That Are Easy to Integrate

Generated code uses C types in a natural way, simplifying integration with external code. You can integrate generated code as source code or libraries. Trusted C libraries or components can be brought into MATLAB for higher-fidelity testing and are automatically called from generated code as well.

Interactive traceability report using MATLAB Coder with Embedded Coder.

Optimize the Performance of Generated Code

Apply optimizations to adjust tradeoffs between execution speed, memory usage, readability, and portability. Use profiling tools to identify bottlenecks. To further boost performance, generate multicore OpenMP code and call optimized libraries such as LAPACK, BLAS, and FFTW when available.

Example of generated code with calls to OpenMP.

Reuse MATLAB Tests on Generated Code Prior to Integration

Reuse existing MATLAB tests to verify the behavior of generated code in the interactive MATLAB environment. Use the MATLAB unit test framework to quickly develop a rich set of regression tests that can be used to verify the generated C code.

Verifying behavior of generated code before integrating with your application.

Accelerate Algorithms

Generate C code and compile it for use inside MATLAB.

Accelerate Algorithms on CPUs

You can call generated code as MEX functions from your MATLAB code to speed execution, though performance will vary depending on the nature of your MATLAB code. You can profile generated MEX functions to identify bottlenecks and focus your optimization efforts.

Profile MEX functions to identify bottlenecks in performance.

Accelerate Algorithms Using GPUs

Use Parallel Computing Toolbox™ to accelerate algorithms running in MATLAB. Use GPU Coder™ to generate CUDA code for acceleration or deployment that runs on any modern NVIDIA® GPU.

Accelerate algorithms using GPUs.

Latest Features

Deep Learning for ARM processors

Generate code for deep learning network with pre/post-processing together using codegen function

Row-Major Array Layout

Simplify interfacing generated code with C environments by storing arrays in row-major layout

Sparse Matrices

Generate code for the backslash operation

OpenMP for macOS

Generate parallel for-loops on macOS platform

MEX Profiling

See execution times of generated MEX functions in MATLAB Profiler

Code Generation Report Object

Access information about code generation programmatically

Statistics and Machine Learning Toolbox™ Code Generation

Update deployed SVM model without regenerating code

Sensor Fusion and Tracking Toolbox™ Code Generation

Generate code to accelerate and deploy your algorithm

See release notes for details on any of these features and corresponding functions.

The Joy of Generating C Code from MATLAB

Learn tips and best practices for working with MATLAB Coder and read about successful applications of generated code by companies such as Delphi, Baker Hughes, iSonea, and dorsaVi.

Get a Free Trial

30 days of exploration at your fingertips.

Download now

Ready to Buy?

Get pricing information and explore related products.

Are You a Student?

Get MATLAB and Simulink student software.

Learn more