Documentation |
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 codegen, use coder.Constant. |
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 dct requires DSP System Toolbox™ software. 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. | |
— | |
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. | |
When called with no output arguments, and without a semicolon at the end, freqz returns the complex frequency response of the input filter, evaluated at 512 points. If the semicolon is added, the function produces a plot of the magnitude and phase response of the filter. | |
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 idct requires DSP System Toolbox software. 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 levinson requires DSP System Toolbox software. 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. | |
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 upfirdn requires DSP System Toolbox software. 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 n as constant, or use the assert function in the calling function to set upper bounds for n. For example, assert(n<10) | |
— | |
If specified, the order of recursion must be a constant. Expressions or variables are allowed if their values do not change. |