Supported Functions

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

barthannwin

Window length must be a constant. Expressions or variables are allowed if their values do not change.

bartlett

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.

bitrevorder

blackman

Window length must be a constant. Expressions or variables are allowed if their values do not change.

blackmanharris

Window length must be a constant. Expressions or variables are allowed if their values do not change.

bohmanwin

Window length must be a constant. Expressions or variables are allowed if their values do not change.

buttap

Filter order must be a constant. Expressions or variables are allowed if their values do not change.

butter

Filter coefficients must be constants. Expressions or variables are allowed if their values do not change.

buttord

All inputs must be constants. Expressions or variables are allowed if their values do not change.

cfirpm

All inputs must be constants. Expressions or variables are allowed if their values do not change.

cheb1ap

All inputs must be constants. Expressions or variables are allowed if their values do not change.

cheb2ap

All inputs must be constants. Expressions or variables are allowed if their values do not change.

cheb1ord

All inputs must be constants. Expressions or variables are allowed if their values do not change.

cheb2ord

All inputs must be constants. Expressions or variables are allowed if their values do not change.

chebwin

All inputs must be constants. Expressions or variables are allowed if their values do not change.

cheby1

All Inputs must be constants. Expressions or variables are allowed if their values do not change.

cheby2

All inputs must be constants. Expressions or variables are allowed if their values do not change.

db2pow

dct

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.

downsample

dpss

All inputs must be constants. Expressions or variables are allowed if their values do not change.

ellip

Inputs must be constant. Expressions or variables are allowed if their values do not change.

ellipap

All inputs must be constants. Expressions or variables are allowed if their values do not change.

ellipord

All inputs must be constants. Expressions or variables are allowed if their values do not change.

filtfilt

Filter coefficients must be constants. Expressions or variables are allowed if their values do not change.

findpeaks

fir1

All inputs must be constants. Expressions or variables are allowed if their values do not change.

fir2

All inputs must be constants. Expressions or variables are allowed if their values do not change.

fircls

All inputs must be constants. Expressions or variables are allowed if their values do not change.

fircls1

All inputs must be constants. Expressions or variables are allowed if their values do not change.

firls

All inputs must be constants. Expressions or variables are allowed if their values do not change.

firpm

All inputs must be constants. Expressions or variables are allowed if their values do not change.

firpmord

All inputs must be constants. Expressions or variables are allowed if their values do not change.

flattopwin

All inputs must be constants. Expressions or variables are allowed if their values do not change.

freqz

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.

See freqz With No Output Arguments.

gausswin

All inputs must be constant. Expressions or variables are allowed if their values do not change.

hamming

All inputs must be constant. Expressions or variables are allowed if their values do not change.

hann

All inputs must be constant. Expressions or variables are allowed if their values do not change.

idct

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.

intfilt

All inputs must be constant. Expressions or variables are allowed if their values do not change.

kaiser

All inputs must be constant. Expressions or variables are allowed if their values do not change.

kaiserord

levinson

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.

maxflat

All inputs must be constant. Expressions or variables are allowed if their values do not change.

nuttallwin

All inputs must be constant. Expressions or variables are allowed if their values do not change.

parzenwin

All inputs must be constant. Expressions or variables are allowed if their values do not change.

pow2db

rcosdesign

All inputs must be constant. Expressions or variables are allowed if their values do not change.

rectwin

All inputs must be constant. Expressions or variables are allowed if their values do not change.

resample

The upsampling and downsampling factors must be specified as constants. Expressions or variables are allowed if their values do not change.

sgolay

All inputs must be constant. Expressions or variables are allowed if their values do not change.

sosfilt

taylorwin

All inputs must be constant. Expressions or variables are allowed if their values do not change.

triang

All inputs must be constant. Expressions or variables are allowed if their values do not change.

tukeywin

All inputs must be constant. Expressions or variables are allowed if their values do not change.

upfirdn

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.

upsample

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)

xcorr

yulewalk

If specified, the order of recursion must be a constant. Expressions or variables are allowed if their values do not change.

Was this topic helpful?