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.
Depending on which feature you wish to use, there are additional required products. For a comprehensive list, see Installing Prerequisite Products in the MATLAB Coder™ documentation.
Code generation from MATLAB supports Signal Processing Toolbox™ functions
listed in the table. To generate C code, you must have the MATLAB Coder software.
If you have the Fixed-Point Designer™ software, you can use fiaccel
to generate MEX code for
fixed-point applications.
To follow the examples in this documentation:
To generate C/C++ code and MEX files with codegen
, install the MATLAB Coder software,
the Signal Processing 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.
Note:
Many Signal Processing Toolbox functions require constant
inputs in generated code. To specify a constant input for |
Function | Remarks/Limitations |
---|---|
Window length must be a constant. Expressions or variables are allowed if their values do not change. | |
Window length must be a constant. Expressions or variables are allowed if their values do not change. | |
besselap | Filter order must be a constant. Expressions or variables are allowed if their values do not change. |
— | |
Window length must be a constant. Expressions or variables are allowed if their values do not change. | |
Window length must be a constant. Expressions or variables are allowed if their values do not change. | |
Window length must be a constant. Expressions or variables are allowed if their values do not change. | |
Filter order must be a constant. Expressions or variables are allowed if their values do not change. | |
Filter coefficients must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All Inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
— | |
C and C++ code generation for Length of transform dimension must be a power of two. If specified, the pad or truncation value must be constant. Expressions or variables are allowed if their values do not change. | |
— | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
Inputs must be constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
Filter coefficients must be constants. Expressions or variables are allowed if their values do not change. Code generation does not support second-order sections as input. You must use transfer functions. | |
— | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
All inputs must be constants. Expressions or variables are allowed if their values do not change. | |
| |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
C and C++ code generation for Length of transform dimension must be a power of two. If specified, the pad or truncation value must be constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
— | |
C and C++ code generation for If specified, the order of recursion must be a constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
— | |
— | |
— | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
C and C++ code generation for The upsampling and downsampling factors must be specified as constants. Expressions or variables are allowed if their values do not change. | |
— | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
— | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
All inputs must be constant. Expressions or variables are allowed if their values do not change. | |
C and C++ code generation for Filter coefficients, upsampling factor, and downsampling factor must be constants. Expressions or variables are allowed if their values do not change. Variable-size inputs are not supported. | |
Either declare input assert(n<10) | |
Leading ones in | |
If specified, the order of recursion must be a constant. Expressions or variables are allowed if their values do not change. |