C Code Generation from MATLAB

What is C Code Generation from MATLAB?

Code generation from MATLAB® is a restricted subset of the MATLAB language that provides optimizations for:

  • Generating efficient, production-quality C/C++ code and MEX files for deployment in desktop and embedded applications. For embedded targets, the subset restricts MATLAB semantics to meet the memory and data type requirements of the target environments.

  • Accelerating fixed-point algorithms

Code generation from MATLAB supports the Communications System Toolbox™ functions listed in Communications System Toolbox. You must have the DSP System Toolbox™ software installed to use this feature. To generate C code, you must have the MATLAB Coder™ software. If you have the Fixed-Point Designer™, you can use fiaccel to generate MEX code for fixed-point applications.

In order to use Communications System Toolbox you must have a Signal Processing Toolbox™ license. There are a number of differences between the use of Signal Processing Toolbox functions with code generation from MATLAB and the use of these functions in the Signal Processing Toolbox software. These differences are summarized in Specifying Inputs in Code Generation for MATLAB and illustrated in Code Generation Examples.

To follow the examples in this documentation:

  • To generate C/C++ code with codegen, install the MATLAB Coder software, the Signal Processing Toolbox, the DSP System Toolbox, and a C compiler. For the Windows® platform, MATLAB supplies a default C compiler. Run mex -setup at the MATLAB command prompt to set up the C compiler.

  • Change to a folder where you have write permission.

Was this topic helpful?