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 combine it with key parts of your existing C and C++ code and libraries. You can also package the generated code as a MEX-function for use in MATLAB.
When used with Embedded Coder, MATLAB Coder provides code customizations, 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. To generate software components for integration with other programming languages, use MATLAB Compiler SDK.
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 startedDeploy 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.
MATLAB Coder Success Stories
Learn how engineers and scientists in a variety of industries use MATLAB Coder to generate C/C++ code for their applications.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.