Main Content

When to Generate Code from MATLAB Algorithms

Generating code from MATLAB® algorithms for desktop and embedded systems allows you to perform your software design, implementation, and testing completely within the MATLAB workspace. You can:

  • Verify that your algorithms are suitable for code generation

  • Generate efficient, readable, and compact C/C++ code automatically, which eliminates the need to manually translate your MATLAB algorithms and minimizes the risk of introducing errors in the code.

  • Modify your design in MATLAB code to take into account the specific requirements of desktop and embedded applications, such as data type management, memory use, and speed.

  • Test the generated code and easily verify that your modified algorithms are functionally equivalent to your original MATLAB algorithms.

  • Generate MEX functions to:

    • Accelerate MATLAB algorithms in certain applications.

    • Speed up fixed-point MATLAB code.

  • Generate hardware description language (HDL) from MATLAB code.

When Not to Generate Code from MATLAB Algorithms

Do not generate code from MATLAB algorithms for the following applications. Use the recommended MathWorks® product instead.

To:Use:
Deploy an application that uses handle graphicsMATLAB Compiler™
Use Java®MATLAB Compiler SDK™
Use toolbox functions that do not support code generationToolbox functions that you rewrite for desktop and embedded applications
Deploy MATLAB based GUI applications on a supported MATLAB hostMATLAB Compiler
Deploy web-based or Windows® applications

MATLAB Compiler SDK

Interface C code with MATLAB

MATLAB mex function