MATLAB Coder

 

MATLAB Coder

Generate C and C++ code from MATLAB code

Get Started:

Free Quick Start Guide for MATLAB Coder

Learn best practices for generating standalone ANSI-C source code and MEX-files from your MATLAB algorithm using MATLAB Coder.

Get started

Run Anywhere

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

Deploy Algorithms Royalty-Free

Use any C/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.

Generated code for matrix multiply.

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 2500 operators and functions from MATLAB and companion toolboxes.

Deploy C++ Code from MATLAB

Integrate generated code with object-oriented C++ source code.

Generate C++ Code with Namespaces

MATLAB Coder can generate C++ code in a namespace, making it easy to integrate with other source code that might have identical function or data type names. The code generator packages all generated functions and type definitions into the namespace.

Generated code that integrates variables with identical data type names using namespaces.

Generated code that integrates variables with identical data type names using namespaces.

Generate C++ Classes from MATLAB Classes

MATLAB Coder produces C++ classes from classes in your MATLAB code, including value classes, handle classes, and system objects. The generated code can be compiled into C++ libraries or executables and can be integrated into your existing C++ source code.

Use Dynamically Allocated C++ Arrays in Generated Function Interfaces

Generate C++ code for MATLAB functions that accept or return an array with an array size unknown at compile time, or whose bound exceeds a predefined threshold. In the generated code, memory for the array is dynamically allocated and implemented as a class template named coder::array. In addition to exception-safe memory deallocation, coder::array provides APIs to access and manage the dynamic array.

Pass dynamically allocated arrays to generated functions.

Pass dynamically allocated arrays to generated functions.

Deploy Deep Learning Networks and Machine Learning Models

Generate code from trained deep learning networks and machine learning models.

Deploy End-To-End Deep Learning Algorithms

Deploy a variety of trained deep learning networks such as ResNet-50 and MobileNet-v2, as well as LSTM and other layers from Deep Learning Toolbox to Intel® and ARM® Cortex® CPUs. Generate code for preprocessing and postprocessing along with your trained deep learning networks to deploy complete algorithms.

Generate Optimized Code for Deep Learning Inference

Because MATLAB Coder generates only the code needed to run inference with your specific algorithm, the code is faster and uses less memory than other deep learning solutions. The generated code calls optimized libraries, including Intel MKL-DNN for Intel processors and ARM Compute Library for ARM Cortex processors. Use GPU Coder to accelerate or deploy algorithms by generating CUDA® code that runs on any modern NVIDIA® GPU.

Deploy End-to-End Machine Learning Models

Deploy statistics and machine learning models by generating C/C++ code for your entire machine learning algorithm, including preprocessing and postprocessing. Update parameters of deployed models without regenerating the C/C++ prediction code.

Code generation workflow for machine learning models.

Code generation workflow for machine learning models.

Prototype on Hardware

Get to hardware fast with automatic conversion of your algorithm to C/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.

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.

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.

Profile execution time of the generated standalone code.

Integrate with Software

Reuse MATLAB algorithms as C/C++ code within your software environment.

Generate Code with Simple Interfaces That Are Easy to Integrate

Generated code uses C/C++ types in a natural way, simplifying integration with external code. You can integrate generated code as source code or libraries. Trusted C/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.

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.

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/C++ code.

Verifying behavior of generated code before integrating with your application.

Verifying behavior of generated code before integrating with your application.

Accelerate Algorithms

Generate C/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.

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.