Main Content

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 (MATLAB Coder).

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`

(Fixed-Point Designer) 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`

(MATLAB Coder), 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.

An asterisk (*) indicates that the reference page has usage notes and limitations for C/C++ code generation.

Absolute value and complex magnitude | |

Align two signals by delaying earliest signal | |

Phase angle | |

Band power | |

Modified Bartlett-Hann window | |

Bartlett window | |

Bessel analog lowpass filter prototype | |

Bilinear transformation method for analog-to-digital filter conversion | |

Convert binary mask to matrix of ROI limits | |

Permute data into bit-reversed order | |

Blackman window | |

Minimum four-term Blackman-Harris window | |

Bohman window | |

Butterworth filter prototype | |

Butterworth filter design | |

Butterworth filter order and cutoff frequency | |

Complex cepstral analysis | |

Modulo-n circular convolution | |

Complex and nonlinear-phase equiripple FIR filter design | |

Chebyshev Type I analog lowpass filter prototype | |

Chebyshev Type I filter order | |

Chebyshev Type II analog lowpass filter prototype | |

Chebyshev Type II filter order | |

Chebyshev window | |

Chebyshev Type I filter design | |

Chebyshev Type II filter design | |

Swept-frequency cosine | |

| Convolution and polynomial multiplication |

2-D convolution | |

Convolution matrix | |

Correlation coefficients | |

Data matrix for autocorrelation matrix estimation | |

| Covariance |

Cross power spectral density | |

Cumulative maximum | |

Cumulative minimum | |

Detect small changes in mean using cumulative sum | |

| Chirp Z-transform |

Convert decibels to power | |

| Discrete cosine transform |

Deconvolution and polynomial division | |

Remove polynomial trend | |

Discrete Fourier transform matrix | |

Dirichlet or periodic sinc function | |

Decrease sample rate by integer factor | |

| Discrete prolate spheroidal (Slepian) sequences |

Distance between signals using dynamic time warping | |

Edit distance on real signals | |

Elliptic filter design | |

Elliptic analog lowpass filter prototype | |

Minimum order for elliptic filters | |

| Empirical mode decomposition |

Equivalent noise bandwidth | |

Signal envelope | |

Envelope spectrum for machinery diagnosis | |

Equalize lengths of transfer function's numerator and denominator | |

Extend signal regions of interest to left and right | |

Extract signal regions of interest | |

Fall time of negative-going bilevel waveform transitions | |

| Fast Fourier transform |

| 2-D fast Fourier transform |

FFT-based FIR filtering using overlap-add method | |

Shift zero-frequency component to center of spectrum | |

Detect and replace outliers in data | |

1-D digital filter | |

2-D digital filter | |

Zero-phase digital filtering | |

Filter order | |

Estimate delay(s) between signals | |

Find local maxima | |

Find signal location using similarity search | |

Window-based FIR filter design | |

| Frequency sampling-based FIR filter design |

Constrained-least-squares FIR multiband filter design | |

Constrained-least-squares linear-phase FIR lowpass and highpass filter design | |

Least-squares linear-phase FIR filter design | |

Parks-McClellan optimal FIR filter design | |

Parks-McClellan optimal FIR filter order estimation | |

Flat top weighted window | |

Frequency spacing for frequency response | |

Frequency response of digital filter | |

| Fourier synchrosqueezed transform |

Fast Walsh-Hadamard transform | |

Gaussian-modulated sinusoidal RF pulse | |

Gaussian window | |

Gaussian monopulse | |

Discrete Fourier transform with second-order Goertzel algorithm | |

Hamming window | |

Hann (Hanning) window | |

| Hilbert-Huang transform |

Discrete-time analytic signal using Hilbert transform | |

Inverse complex cepstrum | |

| Inverse discrete cosine transform |

| Inverse fast Fourier transform |

2-D inverse fast Fourier transform | |

Inverse zero-frequency shift | |

Inverse Fourier synchrosqueezed transform | |

Inverse Fast Walsh-Hadamard transform | |

Estimate instantaneous frequency | |

1-D data interpolation (table lookup) | |

Interpolation FIR filter design | |

Determine whether window-overlap combination is COLA compliant | |

Find outliers in data | |

Inverse short-time Fourier transform | |

Kaiser window | |

Kaiser window FIR filter design estimation parameters | |

Visualize spectral kurtosis | |

Levinson-Durbin recursion | |

Transform lowpass analog filters to bandpass | |

Transform lowpass analog filters to bandstop | |

Transform lowpass analog filters to highpass | |

Change cutoff frequency for lowpass analog filter | |

Convert line spectral frequencies to prediction filter coefficients | |

| Maximum elements of an array |

Generalized digital Butterworth filter design | |

| Average or mean value of array |

Mean frequency | |

Median frequency | |

Median value of array | |

Merge signal regions of interest | |

| Minimum elements of an array |

Moving median absolute deviation | |

Moving median | |

Magnitude-squared coherence | |

Nuttall-defined minimum 4-term Blackman-Harris window | |

Occupied bandwidth | |

Average spectrum versus order for vibration signal | |

Track and extract order magnitudes from vibration signal | |

Extract time-domain order waveforms from vibration signal | |

Parzen (de la Vallée Poussin) window | |

Piecewise Cubic Hermite Interpolating Polynomial (PCHIP) | |

Maximum-to-minimum difference | |

Peak-magnitude-to-RMS ratio | |

Spectral entropy of signal | |

Periodogram power spectral density estimate | |

Spectral kurtosis from signal or spectrogram | |

Lomb-Scargle periodogram | |

Convert prediction filter polynomial to autocorrelation sequence | |

Convert prediction filter coefficients to line spectral frequencies | |

Convert prediction filter polynomial to reflection coefficients | |

Convert power to decibels | |

Power bandwidth | |

Analyze signals in the frequency and time-frequency domains | |

Pulse train | |

Welch's power spectral density estimate | |

Rainflow counts for fatigue analysis | |

Normally distributed random numbers | |

Convert reflection coefficients to autocorrelation sequence | |

Convert reflection coefficients to prediction filter polynomial | |

Real cepstrum and minimum-phase reconstruction | |

Raised cosine FIR pulse-shaping filter design | |

Sampled aperiodic rectangle | |

Rectangular window | |

Remove signal regions of interest | |

Resample uniform or nonuniform data to new fixed rate | |

Rise time of positive-going bilevel waveform transitions | |

Reverse Levinson-Durbin recursion | |

Root-mean-square level | |

Frequency-RPM map for order analysis | |

Order-RPM map for order analysis | |

| Root-sum-of-squares level |

Sawtooth or triangle wave | |

| Spurious free dynamic range |

Savitzky-Golay filter design | |

Savitzky-Golay filtering | |

Shorten signal regions of interest from left and right | |

Convert matrix of ROI limits to binary mask | |

Sine of argument in radians | |

Signal to noise and distortion ratio | |

Sinc function | |

Smooth noisy data | |

| Signal-to-noise ratio |

Convert digital filter second-order section data to transfer function form | |

Second-order (biquadratic) IIR digital filtering | |

Spectrogram using short-time Fourier transform | |

Cubic spline data interpolation | |

Square wave | |

State-level estimation for bilevel waveform with histogram method | |

| Standard deviation |

Short-time Fourier transform | |

Signal reconstruction from STFT magnitude | |

Extract RPM signal from tachometer pulses | |

Taylor window | |

Convert transfer function filter parameters to state-space form | |

Transfer function estimate | |

Time-frequency ridges | |

| Total harmonic distortion |

| Third-order intercept point |

Triangular window | |

Sampled aperiodic triangle | |

| Time-synchronous signal average |

Tukey (tapered cosine) window | |

Shift phase angles | |

Upsample, apply FIR filter, and downsample | |

Increase sample rate by integer factor | |

| Variance |

| Variational mode decomposition |

| Wigner-Ville distribution and smoothed pseudo Wigner-Ville distribution |

Cross-correlation | |

2-D cross-correlation | |

Cross-covariance | |

Cross-spectrogram using short-time Fourier transforms | |

| Cross Wigner-Ville distribution and cross smoothed pseudo Wigner-Ville distribution |

Recursive digital filter design | |

Convert zero-pole-gain filter parameters to state-space form | |

Convert zero-pole-gain filter parameters to transfer function form |