Documentation Center

  • Trial Software
  • Product Updates

Functions and Objects Supported for C and C++ Code Generation — Categorical List

Aerospace Toolbox

C and C++ code generation for the following Aerospace Toolbox quaternion functions requires the Aerospace Blockset™ software.

Function

Remarks and Limitations

quatconj

quatdivide

quatinv

quatmod

quatmultiply

quatnorm

quatnormalize

Arithmetic Operations in MATLAB

See Array vs. Matrix Operations for detailed descriptions of the following operator equivalent functions.

Function

Remarks and Limitations

ctranspose

idivide

  • For efficient generated code, MATLAB® rules for divide by zero are supported only for the 'round' option.

isa

ldivide

minus

mldivide

mpower

mrdivide

mtimes

Variable Sizing Restrictions for Code Generation of Toolbox Functions

plus

power

  • Generates an error during simulation. When both X and Y are real, but power(X,Y) is complex, returns NaN in the generated code. To get the complex result, make the input value X complex by passing in complex(X). For example, power(complex(X),Y).

  • Generates an error during simulation. When both X and Y are real, but X .^ Y is complex, returns NaN in generated code. To get the complex result, make the input value X complex by using complex(X). For example, complex(X).^Y.

rdivide

times

transpose

uminus

uplus

Bit-Wise Operations MATLAB

Function

Remarks and Limitations

flintmax

swapbytes

Inheritance of the class of the input to swapbytes in a MATLAB Function block is supported only when the class of the input is double. For non-double inputs, the input port data types must be specified, not inherited.

Casting in MATLAB

Function

Remarks and Limitations

cast

char

class

double

int8, int16, int32, int64

No integer overflow detection for int64 in MEX or MATLAB Function block simulation on Windows® 32-bit platforms.

logical

single

typecast

uint8, uint16, uint32, uint64

No integer overflow detection for int64 in MEX or MATLAB Function block simulation on Windows 32-bit platforms.

Communications System Toolbox

C and C++ code generation for the following functions and System objects requires the Communications System Toolbox™ software.

NameRemarks and Limitations
Input and Output

comm.BarkerCode

Code Generation with System Objects and Functions

comm.GoldSequence

Code Generation with System Objects and Functions

comm.HadamardCode

Code Generation with System Objects and Functions

comm.KasamiSequence

Code Generation with System Objects and Functions

comm.WalshCode

Code Generation with System Objects and Functions

comm.PNSequence

Code Generation with System Objects and Functions

lteZadoffChuSeq

Signal and Delay Management

bi2de

de2bi

Display and Visual Analysis

comm.ConstellationDiagram

Code Generation with System Objects and Functions

dsp.ArrayPlot

Code Generation with System Objects and Functions

dsp.SpectrumAnalyzer

Code Generation with System Objects and Functions

dsp.TimeScope

Code Generation with System Objects and Functions

Source Coding
comm.DifferentialDecoder

Code Generation with System Objects and Functions

comm.DifferentialEncoder

Code Generation with System Objects and Functions

Cyclic Redundancy Check Coding

comm.CRCDetector

Code Generation with System Objects and Functions

comm.CRCGenerator

Code Generation with System Objects and Functions

comm.HDLCRCDetector

Code Generation with System Objects and Functions

comm.HDLCRCGenerator

Code Generation with System Objects and Functions

BCH Codes

comm.BCHDecoder

Code Generation with System Objects and Functions

comm.BCHEncoder

Code Generation with System Objects and Functions

Reed-Solomon Codes

comm.RSDecoder

Code Generation with System Objects and Functions

comm.RSEncoder

Code Generation with System Objects and Functions

comm.HDLRSDecoder

Code Generation with System Objects and Functions

comm.HDLRSEncoder

Code Generation with System Objects and Functions

LDPC Codes

comm.LDPCDecoder

Code Generation with System Objects and Functions

comm.LDPCEncoder

Code Generation with System Objects and Functions

Convolutional Coding

comm.APPDecoder

Code Generation with System Objects and Functions

comm.ConvolutionalEncoder

Code Generation with System Objects and Functions

comm.TurboDecoder

Code Generation with System Objects and Functions

comm.TurboEncoder

Code Generation with System Objects and Functions

comm.ViterbiDecoder

Code Generation with System Objects and Functions

istrellis

poly2trellis

Signal Operations

comm.Descrambler

Code Generation with System Objects and Functions

comm.Scrambler

Code Generation with System Objects and Functions

Interleaving

comm.AlgebraicDeinterleaver

Code Generation with System Objects and Functions

comm.AlgebraicInterleaver

Code Generation with System Objects and Functions

comm.BlockDeinterleaver

Code Generation with System Objects and Functions

comm.BlockInterleaver

Code Generation with System Objects and Functions

comm.ConvolutionalDeinterleaver

Code Generation with System Objects and Functions

comm.ConvolutionalInterleaver

Code Generation with System Objects and Functions

comm.HelicalDeinterleaver

Code Generation with System Objects and Functions

comm.HelicalInterleaver

Code Generation with System Objects and Functions

comm.MatrixDeinterleaver

Code Generation with System Objects and Functions

comm.MatrixInterleaver

Code Generation with System Objects and Functions

comm.MatrixHelicalScanDeinterleaver

Code Generation with System Objects and Functions

comm.MatrixHelicalScanInterleaver

Code Generation with System Objects and Functions

comm.MultiplexedDeinterleaver

Code Generation with System Objects and Functions

comm.MultiplexedInterleaver

Code Generation with System Objects and Functions

Frequency Modulation

comm.FSKDemodulator

Code Generation with System Objects and Functions

comm.FSKModulator

Code Generation with System Objects and Functions

Phase Modulation
comm.BPSKDemodulator

Code Generation with System Objects and Functions

comm.BPSKModulator

Code Generation with System Objects and Functions

comm.DBPSKDemodulator

Code Generation with System Objects and Functions

comm.DBPSKModulator

Code Generation with System Objects and Functions

comm.DPSKDemodulator

Code Generation with System Objects and Functions

comm.DPSKModulator

Code Generation with System Objects and Functions

comm.DQPSKDemodulator

Code Generation with System Objects and Functions

comm.DQPSKModulator

Code Generation with System Objects and Functions

comm.OQPSKDemodulator

Code Generation with System Objects and Functions

comm.OQPSKModulator

Code Generation with System Objects and Functions

comm.PSKDemodulator

Code Generation with System Objects and Functions

comm.PSKModulator

Code Generation with System Objects and Functions

comm.QPSKDemodulator

Code Generation with System Objects and Functions

comm.QPSKModulator

Code Generation with System Objects and Functions

Amplitude Modulation
comm.GeneralQAMDemodulator

Code Generation with System Objects and Functions

comm.GeneralQAMModulator

Code Generation with System Objects and Functions

comm.PAMDemodulator

Code Generation with System Objects and Functions

comm.PAMModulator

Code Generation with System Objects and Functions

comm.RectangularQAMDemodulator

Code Generation with System Objects and Functions

comm.RectangularQAMModulator

Code Generation with System Objects and Functions

Continuous Phase Modulation
comm.CPFSKDemodulator

Code Generation with System Objects and Functions

comm.CPFSKModulator

Code Generation with System Objects and Functions

comm.CPMDemodulator

Code Generation with System Objects and Functions

comm.CPMModulator

Code Generation with System Objects and Functions

comm.GMSKDemodulator

Code Generation with System Objects and Functions

comm.GMSKModulator

Code Generation with System Objects and Functions

comm.MSKDemodulator

Code Generation with System Objects and Functions

comm.MSKModulator

Code Generation with System Objects and Functions

Trellis Coded Modulation
comm.GeneralQAMTCMDemodulator

Code Generation with System Objects and Functions

comm.GeneralQAMTCMModulator

Code Generation with System Objects and Functions

comm.PSKTCMDemodulator

Code Generation with System Objects and Functions

comm.PSKTCMModulator

Code Generation with System Objects and Functions

comm.RectangularQAMTCMDemodulator

Code Generation with System Objects and Functions

comm.RectangularQAMTCMModulator

Code Generation with System Objects and Functions

Orthogonal Frequency-Division Modulation
comm.OFDMDemodulator

Code Generation with System Objects and Functions

comm.OFDMModulator

Code Generation with System Objects and Functions

Filtering
comm.IntegrateAndDumpFilter

Code Generation with System Objects and Functions

comm.RaisedCosineReceiveFilter

Code Generation with System Objects and Functions

comm.RaisedCosineTransmitFilter

Code Generation with System Objects and Functions

Carrier Phase Synchronization
comm.CPMCarrierPhaseSynchronizer

Code Generation with System Objects and Functions

comm.PSKCarrierPhaseSynchronizer

Code Generation with System Objects and Functions

Timing Phase Synchronization
comm.EarlyLateGateTimingSynchronizer

Code Generation with System Objects and Functions

comm.GardnerTimingSynchronizer

Code Generation with System Objects and Functions

comm.GMSKTimingSynchronizer

Code Generation with System Objects and Functions

comm.MSKTimingSynchronizer

Code Generation with System Objects and Functions

comm.MuellerMullerTimingSynchronizer

Code Generation with System Objects and Functions

Synchronization Utilities
comm.DiscreteTimeVCO

Code Generation with System Objects and Functions

Equalization
comm.MLSEEqualizer

Code Generation with System Objects and Functions

MIMO
comm.LTEMIMOChannel

Code Generation with System Objects and Functions

comm.MIMOChannel

Code Generation with System Objects and Functions

comm.OSTBCCombiner

Code Generation with System Objects and Functions

comm.OSTBCEncoder

Code Generation with System Objects and Functions

comm.SphereDecoder

Code Generation with System Objects and Functions

Channel Modeling and RF Impairments
comm.AGC

Code Generation with System Objects and Functions

comm.AWGNChannel

Code Generation with System Objects and Functions

comm.BinarySymmetricChannel

Code Generation with System Objects and Functions

comm.LTEMIMOChannel

Code Generation with System Objects and Functions

comm.MemorylessNonlinearity

Code Generation with System Objects and Functions

comm.MIMOChannel

Code Generation with System Objects and Functions

comm.PhaseFrequencyOffset

Code Generation with System Objects and Functions

comm.PhaseNoise

Code Generation with System Objects and Functions

comm.RayleighChannel

Code Generation with System Objects and Functions

comm.RicianChannel

Code Generation with System Objects and Functions

comm.ThermalNoise

Code Generation with System Objects and Functions

comm.PSKCoarseFrequencyEstimator

Code Generation with System Objects and Functions

comm.QAMCoarseFrequencyEstimator

Code Generation with System Objects and Functions

Measurements and Analysis
comm.ACPR

Code Generation with System Objects and Functions

comm.CCDF

Code Generation with System Objects and Functions

comm.ErrorRate

Code Generation with System Objects and Functions

comm.EVM

Code Generation with System Objects and Functions

comm.MER

Code Generation with System Objects and Functions

Complex Numbers in MATLAB

Function

Remarks and Limitations

complex

conj

imag

isnumeric

isreal

isscalar

real

unwrap

  • Row vector input is only supported when the first two inputs are vectors and nonscalar

  • Performs arithmetic in the output class. Hence, results might not match MATLAB due to different rounding errors

Computer Vision System Toolbox

C and C++ code generation for the following functions and System objects requires the Computer Vision System Toolbox™ software.

NameRemarks and Limitations
Feature Detection, Extraction, and Matching
BRISKPointsCompile-time constant inputs: No restriction
Supports MATLAB Function block: No
To index locations with this object, use the syntax: points.Location(idx,:), for points object. See visionRecovertformCodeGeneration_kernel.mvisionRecovertformCodeGeneration_kernel.m, which is used in the Introduction to Code Generation with Feature Matching and Registration example.
cornerPointsCompile-time constant input: No restriction
Supports MATLAB Function block: No
To index locations with this object, use the syntax: points.Location(idx,:), for points object. See visionRecovertformCodeGeneration_kernel.mvisionRecovertformCodeGeneration_kernel.m, which is used in the Introduction to Code Generation with Feature Matching and Registration example.
detectBRISKFeaturesSupports MATLAB Function block: No
Generated code for this function uses a precompiled platform-specific shared library.
detectFASTFeaturesSupports MATLAB Function block: No
Generated code for this function uses a precompiled platform-specific shared library.
detectHarrisFeaturesCompile-time constant input: FilterSize
Supports MATLAB Function block: No
Generated code for this function uses a precompiled platform-specific shared library.
detectMinEigenFeaturesCompile-time constant input: FilterSize
Supports MATLAB Function block: No
Generated code for this function uses a precompiled platform-specific shared library.
detectMSERFeaturesCompile-time constant input: No restriction
Supports MATLAB Function block: No
For code generation, the function outputs regions.PixelList as an array. The region sizes are defined in regions.Lengths.
detectSURFFeaturesCompile-time constant input: No restrictions
Supports MATLAB Function block: No
Generated code for this function uses a precompiled platform-specific shared library.
extractFeaturesGenerates platform-dependent library: Yes for BRISK, FREAK, and SURF methods only.
Compile-time constant input: Method
Supports MATLAB Function block: Yes for Block method only.
Generated code for this function uses a precompiled platform-specific shared library.
extractHOGFeaturesCompile-time constant input: No
Supports MATLAB Function block: No
matchFeaturesGenerates platform-dependent library: Yes for MATLAB host. The function generates portable C code for non-host target.
Compile-time constant input: Method and Metric.
Supports MATLAB Function block: Yes
Generated code for this function uses a precompiled platform-specific shared library.
MSERRegionsCompile-time constant input: No restrictions.
Supports MATLAB Function block: Yes
For code generation, you must specify both the pixellist cell array and the length of each array, as the second input. The object outputs, regions.PixelList as an array. The region sizes are defined in regions.Lengths.
Generated code for this function uses a precompiled platform-specific shared library.
SURFPointsCompile-time constant input: No restrictions.
Supports MATLAB Function block: No
To index locations with this object, use the syntax: points.Location(idx,:), for points object. See visionRecovertformCodeGeneration_kernel.mvisionRecovertformCodeGeneration_kernel.m, which is used in the Introduction to Code Generation with Feature Matching and Registration example.
vision.BoundaryTracerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.EdgeDetectorSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
Image Registration and Geometric Transformations
estimateGeometricTransformCompile-time constant input: transformType
Supports MATLAB Function block: No
vision.GeometricRotatorSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.GeometricScalerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.GeometricShearerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.GeometricTransformerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.GeometricTranslatorSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
Object Detection and Recognition
ocrCompile-time constant input: TextLayout, Language, and CharacterSet.
Supports MATLAB Function block: No
Generated code for this function uses a precompiled platform-specific shared library.
ocrTextCompile-time constant input: No restrictions.
Supports MATLAB Function block: No
vision.PeopleDetectorSupports MATLAB Function block: No
Generated code for this function uses a precompiled platform-specific shared library.
System Objects in MATLAB Code Generation
vision.CascadeObjectDetectorSupports MATLAB Function block: No
Generated code for this function uses a precompiled platform-specific shared library.
System Objects in MATLAB Code Generation
Tracking and Motion Estimation
assignDetectionsToTracksCompile-time constant input: No restriction.
Supports MATLAB Function block: Yes
vision.ForegroundDetectorSupports MATLAB Function block: No
Generated code for this function uses a precompiled platform-specific shared library.
System Objects in MATLAB Code Generation
vision.HistogramBasedTrackerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.KalmanFilterSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.PointTrackerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.TemplateMatcherSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
Camera Calibration and Stereo Vision
disparityCompile-time constant input: Method.
Supports MATLAB Function block: No
Generated code for this function uses a precompiled platform-specific shared library.
epipolarlineCompile-time constant input: No restrictions.
Supports MATLAB Function block: Yes
estimateFundamentalMatrixCompile-time constant input: Method, OutputClass, DistanceType, and ReportRuntimeError.
Supports MATLAB Function block: Yes
estimateUncalibratedRectificationCompile-time constant input: transformType
Supports MATLAB Function block: No
isEpipoleInImageCompile-time constant input: No restrictions.
Supports MATLAB Function block: Yes
lineToBorderPointsCompile-time constant input: No restrictions.
Supports MATLAB Function block: Yes
Statistics
vision.AutocorrelatorSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.BlobAnalysisSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.CrosscorrelatorSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.HistogramSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.LocalMaximaFinderSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.MaximumSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.MeanSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.MedianSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.MinimumSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.PSNRSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.StandardDeviationSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.VarianceSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
Morphological Operations
vision.ConnectedComponentLabelerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.MorphologicalCloseSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.MorphologicalDilateSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.MorphologicalErodeSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.MorphologicalOpenSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
Filters, Transforms, and Enhancements
integralImageSupports MATLAB Function block: Yes
vision.ConvolverSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.ContrastAdjusterSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.DCTSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.DeinterlacerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.EdgeDetectorSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.FFTSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.HistogramEqualizerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.HoughLinesSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.HoughTransformSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.IDCTSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.IFFTSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.ImageFilterSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.MedianFilterSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.PyramidSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
Video Loading, Saving, and Streaming
vision.DeployableVideoPlayerGenerates code on Windows host only.
Generated code for this function uses a precompiled platform-specific shared library.
System Objects in MATLAB Code Generation
vision.VideoFileReaderSupports MATLAB Function block: Yes
Generated code for this function uses a precompiled platform-specific shared library.
System Objects in MATLAB Code Generation
vision.VideoFileWriterSupports MATLAB Function block: Yes
Generated code for this function uses a precompiled platform-specific shared library.
System Objects in MATLAB Code Generation
Color Space Formatting and Conversions
vision.AutothresholderSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.ChromaResamplerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.ColorSpaceConverterSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.DemosaicInterpolatorSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.GammaCorrectorSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.ImageComplementerSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.ImageDataTypeConverterSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.ImagePadderSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
Graphics
insertMarkerCompile-time constant input: marker
Supports MATLAB Function block: Yes
insertShapeCompile-time constant input: shape and SmoothEdges
Supports MATLAB Function block: Yes
vision.AlphaBlenderSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.MarkerInserterSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.ShapeInserterSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation
vision.TextInserterSupports MATLAB Function block: Yes
System Objects in MATLAB Code Generation

Control Flow in MATLAB

Function

Remarks and Limitations

break

continue

end

for

if, elseif, else

parfor

Treated as a for-loop when used with fiaccel.

return

switch, case, otherwise

  • If all case expressions are scalar integer values, generates a C switch statement. At run time, if the switch value is not an integer, generates an error.

  • When the case expressions contain noninteger or nonscalar values, the code generation software generates C if statements in place of a C switch statement.

while

Data and File Management in MATLAB

Function

Remarks and Limitations

computer

  • Information about the computer on which the code generation software is running.

  • Use only when the code generation target is S-function (Simulation) or MEX-function.

fclose

fopen

  • Does not support:

    • machineformat, encoding, or fileID inputs

    • message output

    • fopen(‘all')

  • If you disable extrinsic calls, you cannot return fileIDs created with fopen to MATLAB or extrinsic functions. You can only use such fileIDs internally.

  • You can open up to 20 files when generating C/C++ executables, static libraries, or dynamic libraries.

  • The generated code does not report errors from invalid file identifiers. Write your own file open error handling in your MATLAB code. Test whether fopen returns -1 which indicates that the file open failed. For example:

    ...
    fid = fopen(filename, 'r');
    if fid == -1
    		% fopen failed
    
    else
    %fopen successful, okay to call fread
    A = fread(fid);
    ...

fprintf

  • Does not support:

    • b and t subtypes on %u, %o %x, and %X formats

    • $ flag for reusing input arguments

    • printing arrays

  • There is no automatic casting. Input arguments must match their format types for predictable results.

  • Escaped characters are limited to the decimal range of 0–127.

  • A call to fprintf with fileID equal to 1 or 2 becomes printf in the generated C/C++ code in the following cases:

    • The fprintf call is inside a parfor loop.

    • Extrinsic calls are disabled.

  • When the MATLAB behavior differs from the C compiler behavior, fprintf matches the C compiler behavior in the following cases:

    • The format specifier has a corresponding C format specifier, for example, %e or %E.

    • The fprintf call is inside a parfor loop.

    • Extrinsic calls are disabled.

  • When you call fprintf with the format specifier %s, do not put a null character in the middle of the input string. Use fprintf(fid, '%c', char(0)) to write a null character.

  • When you call fprintf with an integer format specifier, the type of the integer argument must be a type that the target hardware can represent as a native C type. For example, if you call fprintf('%d', int64(n)), the target hardware must have a native C type that supports a 64-bit integer.

fread

  • precision must be a constant.

  • The source and output that precision specifies cannot have values long, ulong, unsigned long, bitN, or ubitN.

  • You cannot use the machineformat input.

  • If the source or output that precision specifies is a C type, for example, int, the target and production sizes for that type must:

    • Match.

    • Map directly to a MATLAB type.

  • If the fread call reads the entire file, all of the data must fit in the largest array available for code generation.

  • If sizeA is not constant or contains a nonfinite element, then dynamic memory allocation is required.

  • Treats a char value for source or output as a signed 8-bit integer. Use values only between 0 and 127.

  • The generated code does not report file read errors. Write your own file read error handling in your MATLAB code. Test that the number of bytes read matches the number of bytes that you requested. For example:

    ...
    N = 100;
    [vals, numRead] = fread(fid, N, '*double');
    if numRead ~= N
        %fewer elements read than expected
    end
    ...

load

  • Use only when generating MEX or code for Simulink® simulation. To load compile-time constants, use coder.load.

  • Does not support use of the function without assignment to a structure or array. For example, use S = load(filename), not load(filename).

  • The output S must be the name of a structure or array without any subscripting. For example, S[i] = load('myFile.mat') is not allowed.

  • Arguments to load must be compile-time constant strings.

  • Does not support loading objects.

  • If the MAT-file contains unsupported constructs, use load(filename,variables) to load only the supported constructs.

  • You cannot use save in a function intended for code generation. The code generation software does not support the save function. Furthermore, you cannot use coder.extrinsic with save. Prior to generating code, you can use save to save the workspace data to a MAT-file.

    You must use coder.varsize to explicitly declare variable-size data loaded using the load function.

Data Types in MATLAB

Function

Remarks and Limitations

deal

iscell

isobject

nargchk

  • Output structure does not include stack information.

    Note:   nargchk will be removed in a future release.

narginchk

nargoutchk

str2func

  • String must be constant/known at compile time

structfun

  • Does not support the ErrorHandler option.

  • The number of outputs must be less than or equal to three.

Desktop Environment in MATLAB

Function

Remarks and Limitations

ismac

  • Returns true or false based on the MATLAB version used for code generation.

  • Use only when the code generation target is S-function (Simulation) or MEX-function.

ispc

  • Returns true or false based on the MATLAB version you use for code generation.

  • Use only when the code generation target is S-function (Simulation) or MEX-function.

isunix

  • Returns true or false based on the MATLAB version used for code generation.

  • Use only when the code generation target is S-function (Simulation) or MEX-function.

Discrete Math in MATLAB

Function

Remarks and Limitations

factor

  • The maximum double precision input is 2^33.

  • The maximum single precision input is 2^25.

  • The input n cannot have type int64 or uint64.

gcd

isprime

  • The maximum double precision input is 2^33.

  • The maximum single precision input is 2^25.

  • The input X cannot have type int64 or uint64.

lcm

nchoosek

  • When the first input, x, is a scalar, nchoosek returns a binomial coefficient. In this case, x must be a nonnegative integer. It cannot have type int64 or uint64.

  • When the first input, x, is a vector, nchoosek treats it as a set. In this case, x can have type int64 or uint64.

  • The second input, k, cannot have type int64 or uint64.

  • Variable Sizing Restrictions for Code Generation of Toolbox Functions

primes

  • The maximum double precision input is 2^32.

  • The maximum single precision input is 2^24.

  • The input n cannot have type int64 or uint64.

DSP System Toolbox

C code generation for the following functions and System objects requires the DSP System Toolbox™ license. Many DSP System Toolbox functions require constant inputs for code generation. To specify a constant input for fiaccel, use coder.Constant. For more information, see Specify Constant Inputs at the Command Line.

NameRemarks and Limitations
Estimation

dsp.BurgAREstimator

System Objects in MATLAB Code Generation

dsp.BurgSpectrumEstimator

System Objects in MATLAB Code Generation

dsp.CepstralToLPC

System Objects in MATLAB Code Generation

dsp.CrossSpectrumEstimator

System Objects in MATLAB Code Generation

dsp.LevinsonSolver

System Objects in MATLAB Code Generation

dsp.LPCToAutocorrelation

System Objects in MATLAB Code Generation

dsp.LPCToCepstral

System Objects in MATLAB Code Generation

dsp.LPCToLSF

System Objects in MATLAB Code Generation

dsp.LPCToLSP

System Objects in MATLAB Code Generation

dsp.LPCToRC

System Objects in MATLAB Code Generation

dsp.LSFToLPC

System Objects in MATLAB Code Generation

dsp.LSPToLPC

System Objects in MATLAB Code Generation

dsp.RCToAutocorrelation

System Objects in MATLAB Code Generation

dsp.RCToLPC

System Objects in MATLAB Code Generation

dsp.SpectrumEstimator

System Objects in MATLAB Code Generation

dsp.TransferFunctionEstimator

System Objects in MATLAB Code Generation

Filters

ca2tf

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

cl2tf

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

dsp.AdaptiveLatticeFilter

System Objects in MATLAB Code Generation

dsp.AffineProjectionFilter

System Objects in MATLAB Code Generation

dsp.AllpoleFilter

dsp.BiquadFilter

System Objects in MATLAB Code Generation

dsp.CICDecimator

System Objects in MATLAB Code Generation

dsp.CICInterpolator

System Objects in MATLAB Code Generation

dsp.DigitalFilter

dsp.FastTransversalFilter

System Objects in MATLAB Code Generation

dsp.FilteredXLMSFilter

System Objects in MATLAB Code Generation

dsp.FIRDecimator

System Objects in MATLAB Code Generation

dsp.FIRFilter

dsp.FIRInterpolator

System Objects in MATLAB Code Generation

dsp.FIRRateConverter

System Objects in MATLAB Code Generation

dsp.FrequencyDomainAdaptiveFilter

System Objects in MATLAB Code Generation

dsp.IIRFilter

dsp.KalmanFilter

System Objects in MATLAB Code Generation

dsp.LMSFilter

System Objects in MATLAB Code Generation

dsp.RLSFilter

System Objects in MATLAB Code Generation

firceqrip

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

fireqint

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

firgr

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

  • Does not support syntaxes that have cell array input.

firhalfband

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

firlpnorm

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

  • Does not support syntaxes that have cell array input.

firminphase

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

firnyquist

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

firpr2chfb

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

ifir

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

iircomb

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

iirgrpdelay

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

  • Does not support syntaxes that have cell array input.

iirlpnorm

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

  • Does not support syntaxes that have cell array input.

iirlpnormc

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

  • Does not support syntaxes that have cell array input.

iirnotch

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

iirpeak

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

tf2ca

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

tf2cl

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

Math Operations 

dsp.ArrayVectorAdder

System Objects in MATLAB Code Generation

dsp.ArrayVectorDivider

System Objects in MATLAB Code Generation

dsp.ArrayVectorMultiplier

System Objects in MATLAB Code Generation

dsp.ArrayVectorSubtractor

System Objects in MATLAB Code Generation

dsp.CumulativeProduct

System Objects in MATLAB Code Generation

dsp.CumulativeSum

System Objects in MATLAB Code Generation

dsp.LDLFactor

System Objects in MATLAB Code Generation

dsp.LevinsonSolver

System Objects in MATLAB Code Generation

dsp.LowerTriangularSolver

System Objects in MATLAB Code Generation

dsp.LUFactor

System Objects in MATLAB Code Generation

dsp.Normalizer

System Objects in MATLAB Code Generation

dsp.UpperTriangularSolver

System Objects in MATLAB Code Generation

Quantizers

dsp.ScalarQuantizerDecoder

System Objects in MATLAB Code Generation

dsp.ScalarQuantizerEncoder

System Objects in MATLAB Code Generation

dsp.VectorQuantizerDecoder

System Objects in MATLAB Code Generation

dsp.VectorQuantizerEncoder

System Objects in MATLAB Code Generation

Scopes

dsp.SpectrumAnalyzer

This System object™ does not generate code. It is automatically declared as an extrinsic variable using the coder.extrinsic function.

dsp.TimeScope

This System object does not generate code. It is automatically declared as an extrinsic variable using the coder.extrinsic function.

Signal Management

dsp.Counter

System Objects in MATLAB Code Generation

dsp.DelayLine

System Objects in MATLAB Code Generation

Signal Operations

dsp.Convolver

System Objects in MATLAB Code Generation

dsp.DCBlocker

System Objects in MATLAB Code Generation

dsp.Delay

System Objects in MATLAB Code Generation

dsp.DigitalDownConverter

System Objects in MATLAB Code Generation

dsp.DigitalUpConverter

System Objects in MATLAB Code Generation

dsp.Interpolator

System Objects in MATLAB Code Generation

dsp.NCO

System Objects in MATLAB Code Generation

dsp.PeakFinder

System Objects in MATLAB Code Generation

dsp.PhaseUnwrapper

System Objects in MATLAB Code Generation

dsp.VariableFractionalDelay

System Objects in MATLAB Code Generation

dsp.VariableIntegerDelay

System Objects in MATLAB Code Generation

dsp.Window

dsp.ZeroCrossingDetector

System Objects in MATLAB Code Generation

Sinks

dsp.AudioPlayer

System Objects in MATLAB Code Generation

dsp.AudioFileWriter

System Objects in MATLAB Code Generation

dsp.UDPSender

System Objects in MATLAB Code Generation

Sources

dsp.AudioFileReader

System Objects in MATLAB Code Generation

dsp.AudioRecorder

System Objects in MATLAB Code Generation

dsp.SignalSource

System Objects in MATLAB Code Generation

dsp.SineWave

dsp.UDPReceiver

System Objects in MATLAB Code Generation

Statistics

dsp.Autocorrelator

System Objects in MATLAB Code Generation

dsp.Crosscorrelator

System Objects in MATLAB Code Generation

dsp.Histogram

dsp.Maximum

System Objects in MATLAB Code Generation

dsp.Mean

System Objects in MATLAB Code Generation

dsp.Median

System Objects in MATLAB Code Generation

dsp.Minimum

System Objects in MATLAB Code Generation

dsp.RMS

System Objects in MATLAB Code Generation

dsp.StandardDeviation

System Objects in MATLAB Code Generation

dsp.Variance

System Objects in MATLAB Code Generation

Transforms

dsp.AnalyticSignal

System Objects in MATLAB Code Generation

dsp.DCT

System Objects in MATLAB Code Generation

dsp.FFT

System Objects in MATLAB Code Generation

dsp.IDCT

System Objects in MATLAB Code Generation

dsp.IFFT

System Objects in MATLAB Code Generation

Error Handling in MATLAB

Function

Remarks and Limitations

assert

  • Generates specified error messages at compile time only if all input arguments are constants or depend on constants. Otherwise, generates specified error messages at run time.

  • For standalone code generation, excluded from the generated code.

  • See Rules for Using assert Function.

error

For standalone code generation, excluded from the generated code.

Exponents in MATLAB

Function

Remarks and Limitations

exp

expm

expm1

factorial

log

  • Generates an error during simulation and returns NaN in generated code when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

log2

log10

log1p

nextpow2

nthroot

reallog

realpow

realsqrt

sqrt

  • Generates an error during simulation and returns NaN in generated code when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

Filtering and Convolution in MATLAB

Function

Remarks and Limitations

conv

conv2

convn

deconv

detrend

  • If supplied and not empty, the input argument bp must satisfy the following requirements:

filter

filter2

Fixed-Point Designer

In addition to function-specific limitations listed in the table, the following general limitations apply to the use of Fixed-Point Designer™ functions in generated code or with fiaccel:

  • fipref and quantizer objects are not supported.

  • Word lengths greater than 128 bits are not supported.

  • You cannot change the fimath or numerictype of a given fi variable after that variable has been created.

  • The boolean value of the DataTypeMode and DataType properties are not supported.

  • For all SumMode property settings other than FullPrecision, the CastBeforeSum property must be set to true.

  • You can use parallel for (parfor) loops in code compiled with fiaccel, but those loops are treated like regular for loops.

  • When you compile code containing fi objects with nontrivial slope and bias scaling, you may see different results in generated code than you achieve by running the same code in MATLAB.

  • The general limitations of C/C++ code generated from MATLAB apply. For more information, see MATLAB Language Features Supported for C/C++ Code Generation.

FunctionRemarks/Limitations

abs

N/A

accumneg

N/A

accumpos

N/A

add

  • Code generation in MATLAB does not support the syntax F.add(a,b). You must use the syntax add(F,a,b).

all

N/A

any

N/A

atan2

N/A

bitand

Not supported for slope-bias scaled fi objects.

bitandreduce

N/A

bitcmp

N/A

bitconcat

N/A

bitget

N/A

bitor

Not supported for slope-bias scaled fi objects.

bitorreduce

N/A

bitreplicate

N/A

bitrol

N/A

bitror

N/A

bitset

N/A

bitshift

N/A

bitsliceget

N/A

bitsll

Generated code may not handle out of range shifting.

bitsra

Generated code may not handle out of range shifting.

bitsrl

Generated code may not handle out of range shifting.

bitxor

Not supported for slope-bias scaled fi objects.

bitxorreduce

N/A

ceil

N/A

complex

N/A

conj

N/A

conv

  • Variable-sized inputs are only supported when the SumMode property of the governing fimath is set to Specify precision or Keep LSB.

  • For variable-sized signals, you may see different results between generated code and MATLAB.

    • In the generated code, the output for variable-sized signals is computed using the SumMode property of the governing fimath.

    • In MATLAB, the output for variable-sized signals is computed using the SumMode property of the governing fimath when both inputs are nonscalar. However, if either input is a scalar, MATLAB computes the output using the ProductMode of the governing fimath.

convergent

N/A

cordicabs

Variable-size signals are not supported.

cordicangle

Variable-size signals are not supported.

cordicatan2

Variable-size signals are not supported.

cordiccart2pol

Variable-size signals are not supported.

cordiccexp

Variable-size signals are not supported.

cordiccos

Variable-size signals are not supported.

cordicpol2cart

Variable-size signals are not supported.

cordicrotate

Variable-size signals are not supported.

cordicsin

Variable-size signals are not supported.

cordicsincos

Variable-size signals are not supported.

cos

N/A

ctranspose

N/A

diag

If supplied, the index, k, must be a real and scalar integer value that is not a fi object.

divide

  • Any non-fi input must be constant; that is, its value must be known at compile time so that it can be cast to a fi object.

  • Complex and imaginary divisors are not supported.

  • Code generation in MATLAB does not support the syntax T.divide(a,b).

double

N/A

end

N/A

eps

  • Supported for scalar fixed-point signals only.

  • Supported for scalar, vector, and matrix, fi single and fi double signals.

eq

Not supported for fixed-point signals with different biases.

fi

  • The default constructor syntax without any input arguments is not supported.

  • If the numerictype is not fully specified, the input to fi must be a constant, a fi, a single, or a built-in integer value. If the input is a built-in double value, it must be a constant. This limitation allows fi to autoscale its fraction length based on the known data type of the input.

  • All properties related to data type must be constant for code generation.

  • numerictype object information must be available for nonfixed-point Simulink inputs.

filter

  • Variable-sized inputs are only supported when the SumMode property of the governing fimath is set to Specify precision or Keep LSB.

fimath

  • Fixed-point signals coming in to a MATLAB Function block from Simulink are assigned a fimath object. You define this object in the MATLAB Function block dialog in the Model Explorer.

  • Use to create fimath objects in the generated code.

  • If the ProductMode property of the fimath object is set to anything other than FullPrecision, the ProductWordLength and ProductFractionLength properties must be constant.

  • If the SumMode property of the fimath object is set to anything other than FullPrecision, the SumWordLength and SumFractionLength properties must be constant.

fix

N/A

fixed.Quantizer

N/A

floor

N/A

ge

Not supported for fixed-point signals with different biases.

get

The syntax structure = get(o) is not supported.

getlsb

N/A

getmsb

N/A

gt

Not supported for fixed-point signals with different biases.

hdlram

N/A

horzcat

N/A

imag

N/A

int8int16int32,  int64

N/A

iscolumn

N/A

isempty

N/A

isequal

N/A

isfi

N/A

isfimath

N/A

isfimathlocal

N/A

isfinite

N/A

isinf

N/A

isnan

N/A

isnumeric

N/A

isnumerictype

N/A

isreal

N/A

isrow

N/A

isscalar

N/A

issigned

N/A

isvector

N/A

le

Not supported for fixed-point signals with different biases.

length

N/A

logical

N/A

lowerbound

N/A

lsb

  • Supported for scalar fixed-point signals only.

  • Supported for scalar, vector, and matrix, fi single and double signals.

lt

Not supported for fixed-point signals with different biases.

max

N/A

mean

N/A

median

N/A

min

N/A

minus

Any non-fi input must be constant; that is, its value must be known at compile time so that it can be cast to a fi object.

mpower

  • When the exponent k is a variable and the input is a scalar, the ProductMode property of the governing fimath must be SpecifyPrecision.

  • When the exponent k is a variable and the input is not scalar, the SumMode property of the governing fimath must be SpecifyPrecision.

  • Variable-sized inputs are only supported when the SumMode property of the governing fimath is set to SpecifyPrecision or Keep LSB.

  • For variable-sized signals, you may see different results between the generated code and MATLAB.

    • In the generated code, the output for variable-sized signals is computed using the SumMode property of the governing fimath.

    • In MATLAB, the output for variable-sized signals is computed using the SumMode property of the governing fimath when the first input, a, is nonscalar. However, when a is a scalar, MATLAB computes the output using the ProductMode of the governing fimath.

mpy

  • Code generation in MATLAB does not support the syntax F.mpy(a,b). You must use the syntax mpy(F,a,b).

  • When you provide complex inputs to the mpy function inside of a MATLAB Function block, you must declare the input as complex before running the simulation. To do so, go to the Ports and data manager and set the Complexity parameter for all known complex inputs to On.

mrdivide

N/A

mtimes

  • Any non-fi input must be constant; that is, its value must be known at compile time so that it can be cast to a fi object.

  • Variable-sized inputs are only supported when the SumMode property of the governing fimath is set to SpecifyPrecision or KeepLSB.

  • For variable-sized signals, you may see different results between the generated code and MATLAB.

    • In the generated code, the output for variable-sized signals is computed using the SumMode property of the governing fimath.

    • In MATLAB, the output for variable-sized signals is computed using the SumMode property of the governing fimath when both inputs are nonscalar. However, if either input is a scalar, MATLAB computes the output using the ProductMode of the governing fimath.

ndims

N/A

ne

Not supported for fixed-point signals with different biases.

nearest

N/A

numberofelements

numberofelements will be removed in a future release. Use numel instead.

numel

N/A

numerictype

  • Fixed-point signals coming in to a MATLAB Function block from Simulink are assigned a numerictype object that is populated with the signal's data type and scaling information.

  • Returns the data type when the input is a nonfixed-point signal.

  • Use to create numerictype objects in generated code.

  • All numerictype object properties related to the data type must be constant.

permute

N/A

plus

Any non-fi inputs must be constant; that is, its value must be known at compile time so that it can be cast to a fi object.

pow2

N/A

power

When the exponent k is a variable, the ProductMode property of the governing fimath must be SpecifyPrecision.

qr

N/A

quantize

N/A

range

N/A

rdivide

N/A

real

N/A

realmax

N/A

realmin

N/A

reinterpretcast

N/A

removefimath

N/A

repmat

N/A

rescale

N/A

reshape

N/A

round

N/A

setfimath

N/A

sfi

  • All properties related to data type must be constant for code generation.

sign

N/A

sin

N/A

single

N/A

size

N/A

sort

N/A

sqrt

  • Complex and [Slope Bias] inputs error out.

  • Negative inputs yield a 0 result.

storedInteger

N/A

storedIntegerToDouble

N/A

sub

  • Code generation in MATLAB does not support the syntax F.sub(a,b). You must use the syntax sub(F,a,b).

subsasgn

N/A

subsref

N/A

sum

Variable-sized inputs are only supported when the SumMode property of the governing fimath is set to Specify precision or Keep LSB.

times

  • Any non-fi input must be constant; that is, its value must be known at compile time so that it can be cast to a fi object.

  • When you provide complex inputs to the times function inside of a MATLAB Function block, you must declare the input as complex before running the simulation. To do so, go to the Ports and data manager and set the Complexity parameter for all known complex inputs to On.

transpose

N/A

tril

If supplied, the index, k, must be a real and scalar integer value that is not a fi object.

triu

If supplied, the index, k, must be a real and scalar integer value that is not a fi object.

ufi

  • All properties related to data type must be constant for code generation.

uint8uint16uint32,  uint64

N/A

uminus

N/A

uplus

N/A

upperbound

N/A

vertcat

N/A

Histograms in MATLAB

Function

Remarks and Limitations

hist

  • Histogram bar plotting not supported; call with at least one output argument.

  • If supplied, the second argument x must be a scalar constant.

  • Inputs must be real.

histc

Image Acquisition Toolbox

If you install Image Acquisition Toolbox™ software, you can generate C and C++ code for the VideoDevice System object. See imaq.VideoDevice and Code Generation with VideoDevice System Object.

Image Processing Toolbox

You must have the MATLAB Coder™ software installed to generate C/C++ code from MATLAB for these functions.

FunctionRemarks/Limitations
affine2d

When generating code, you can only specify singular objects—arrays of objects are not supported.

bwlookup

For best results, specify an input image of class logical.

bwmorph

The text string specifying the operation must be a constant and, for best results, specify an input image of class logical.

bwpack

Generated code for this function uses a precompiled platform-specific shared library.

bwselect

Supports only the 3 and 4 input argument syntaxes: BW2 = bwselect(BW,c,r) and BW2 = bwselect(BW,c,r,n). The optional fourth input argument, n, must be a compile-time constant. In addition, with code generation, bwselect only supports only the 1 and 2 output argument  syntaxes: BW2 = bwselect(___) or [BW2, idx] = bwselect(___).

Generated code for this function uses a precompiled platform-specific shared library.

bwunpack

Generated code for this function uses a precompiled platform-specific shared library.

conndef

All input arguments must be compile-time constants.

edge

The method, direction, and sigma arguments must be a compile-time constants. In addition, nonprogrammatic syntaxes are not supported. For example, the syntax edge(im), where edge does not return a value but displays an image instead, is not supported.

Generated code for this function uses a precompiled platform-specific shared library.

fspecial

Allinputs must be compile-time constants. Expressions or variables are allowed if their values do not change.

getrangefromclass
im2uint8

Generated code for this function uses a precompiled platform-specific shared library.

im2uint16

Generated code for this function uses a precompiled platform-specific shared library.

im2int16

Generated code for this function uses a precompiled platform-specific shared library.

im2single
im2double
imbothat

The input image IM must be either 2-D or 3-D image. The structuring element input argument SE must be a compile-time constant.

Generated code for this function uses a precompiled platform-specific shared library.

imclose

The input image IM must be either 2-D or 3-D image. The structuring element input argument SE must be a compile-time constant.

Generated code for this function uses a precompiled platform-specific shared library.

imcomplement

Does not support int64 and uint64 data types.

imdilate

The input image IM must be either 2-D or 3-D image. The SE, PACKOPT, and SHAPE input arguments must be a compile-time constant. The structuring element argument SE must be a single element—arrays of structuring elements are not supported. To obtain the same result as that obtained using an array of structuring elements, call the function sequentially.

Generated code for this function uses a precompiled platform-specific shared library.

imerode

The input image IM must be either 2-D or 3-D image. The SE, PACKOPT, and SHAPE input arguments must be a compile-time constant. The structuring element argument SE must be a single element—arrays of structuring elements are not supported. To obtain the same result as that obtained using an array of structuring elements, call the function sequentially.

Generated code for this function uses a precompiled platform-specific shared library.

imextendedmax

The optional third input argument, conn, must be a compile-time constant.

Generated code for this function uses a precompiled platform-specific shared library.

imextendedmin

The optional third input argument, conn, must be a compile-time constant.

Generated code for this function uses a precompiled platform-specific shared library.

imfill

The optional input connectivity, conn and the string 'holes' must be compile time constants.

Supports only up to 3-D inputs. (No N-D support.)

The interactive mode to select points, imfill(BW,0,CONN) is not supported in code generation.

locations can be a P-by-1 vector, in which case it contains the linear indices of the starting locations. locations can also be a P-by-ndims(I) matrix, in which case each row contains the array indices of one of the starting locations. Once you select a format at compile-time, you cannot change it at run-time. However, the number of points in locations can be varied at run-time.

Generated code for this function uses a precompiled platform-specific shared library.

imfilter

The input image can be either 2-D or 3-D. The value of the input argument, options, must be a compile-time constant.

Generated code for this function uses a precompiled platform-specific shared library.

imhist

The optional second input argument, n, must be a compile-time constant. In addition, nonprogrammatic syntaxes are not supported. For example, the syntaxes where imhist displays the histogram are not supported.

Generated code for this function uses a precompiled platform-specific shared library.

imhmax

The optional third input argument, conn, must be a compile-time constant

Generated code for this function uses a precompiled platform-specific shared library.

imhmin

The optional third input argument, conn, must be a compile-time constant

Generated code for this function uses a precompiled platform-specific shared library.

imopen

The input image IM must be either 2-D or 3-D image. The structuring element input argument SE must be a compile-time constant.

Generated code for this function uses a precompiled platform-specific shared library.

imreconstruct

The optional third input argument, conn, must be a compile-time constant.

Generated code for this function uses a precompiled platform-specific shared library.

imregionalmax

The optional second input argument, conn, must be a compile-time constant.

Generated code for this function uses a precompiled platform-specific shared library.

imregionalmin

The optional second input argument, conn, must be a compile-time constant.

Generated code for this function uses a precompiled platform-specific shared library.

imtophat

The input image IM must be either 2-D or 3-D image. The structuring element input argument SE must be a compile-time constant.

Generated code for this function uses a precompiled platform-specific shared library.

imwarp

Geometric transformation object input, tform, must be either affine2d or projective2d. Additionally, the interpolation method and optional parameter names must be string constants.

Generated code for this function uses a precompiled platform-specific shared library.

imref2d

The XWorldLimits, YWorldLimits and ImageSize properties can be set only during object construction. When generating code, you can only specify singular objects—arrays of objects are not supported.

imref3d

The XWorldLimits, YWorldLimits, ZWorldLimits and ImageSize properties can be set only during object construction. When generating code, you can only specify singular objects—arrays of objects are not supported.

iptcheckconn

All input arguments must be compile-time constants.

label2rgb

Referring to the standard syntax:

RGB = label2rgb(L, map, zerocolor, order)
  • Submit at least two input arguments: the label matrix, L, and the colormap matrix, map.

  • map must be an n-by-3, double, colormap matrix. You cannot use a string containing the name of a MATLAB colormap function or a function handle of a colormap function.

  • If you set the boundary color zerocolor to the same color as one of the regions, label2rgb will not issue a warning.

  • If you supply a value for order, it must be 'noshuffle'.

mean2
padarray

Support only up to 3-D inputs.

Input arguments, padval and direction are expected to be compile-time constants.

projective2d

When generating code, you can only specify singular objects—arrays of objects are not supported.

strelAll input arguments must be compile-time constants. The following methods are not supported for code generation: getsequence, reflect, translate, disp, display, loadobj. When generating code, you can only specify singular objects—arrays of objects are not supported.

Input and Output Arguments in MATLAB

Function

Remarks and Limitations

nargin

nargout

  • For a function with no output arguments, returns 1 if called without a terminating semicolon.

    Note:   This behavior also affects extrinsic calls with no terminating semicolon. nargout is 1 for the called function in MATLAB.

Interpolation and Computational Geometry in MATLAB

Function

Remarks and Limitations

cart2pol

cart2sph

interp1

Variable Sizing Restrictions for Code Generation of Toolbox Functions

interp2

  • Xq and Yq must be the same size. Use meshgrid to evaluate on a grid.

  • For best results, provide X and Y as vectors.

  • For the 'cubic' method, reports an error if the grid does not have uniform spacing. In this case, use the 'spline' method.

  • For best results when you use the 'spline' method:

    • Use meshgrid to create the inputs Xq and Yq.

    • Use a small number of interpolation points relative to the dimensions of V. Interpolating over a large set of scattered points can be inefficient.

interp3

  • Xq, Yq, and Zq must be the same size. Use meshgrid to evaluate on a grid.

  • For best results, provide X, Y, and Z as vectors.

  • For the 'cubic' method, reports an error if the grid does not have uniform spacing. In this case, use the 'spline' method.

  • For best results when you use the 'spline' method:

    • Use meshgrid to create the inputs Xq, Yq, and Zq.

    • Use a small number of interpolation points relative to the dimensions of V. Interpolating over a large set of scattered points can be inefficient.

meshgrid

mkpp

  • The output structure pp differs from the pp structure in MATLAB. In MATLAB, ppval cannot use the pp structure from the code generation software. For code generation, ppval cannot use a pp structure created by MATLAB. unmkpp can use a MATLAB pp structure for code generation.

    To create a MATLAB pp structure from a pp structure created by the code generation software:

    • In code generation, use unmkpp to return the piecewise polynomial details to MATLAB.

    • In MATLAB, use mkpp to create the pp structure.

  • If you do not provide d, then coefs must be two-dimensional and have a fixed number of columns. In this case, the number of columns is the order.

  • To define a piecewise constant polynomial, coefs must be a column vector or d must have at least two elements.

  • If you provide d and d is 1, d must be a constant. Otherwise, if the input to ppval is nonscalar, the shape of the output of ppval can differ from ppval in MATLAB.

  • If you provide d, it must have a fixed length. One of the following sets of statements must be true:

    1. Suppose that m = length(d) and npieces = length(breaks) - 1.

      size(coefs,j) = d(j) 
      size(coefs,m+1) = npieces
      size(coefs,m+2) = order 

      j = 1,2,...,m. The dimension m+2 must be fixed length.

    2. Suppose that m = length(d) and npieces = length(breaks) - 1.

      size(coefs,1) = prod(d)*npieces
      size(coefs,2) = order             

      The second dimension must be fixed length.

  • If you do not provide d, the following statements must be true:

    Suppose that m = length(d) and npieces = length(breaks) - 1.

    size(coefs,1) = prod(d)*npieces
    size(coefs,2) = order

    The second dimension must be fixed length.

pchip

  • Input x must be strictly increasing.

  • Does not remove y entries with NaN values.

  • If you generate code for the pp = pchip(x,y) syntax, you cannot input pp to the ppval function in MATLAB. To create a MATLAB pp structure from a pp structure created by the code generation software:

    • In code generation, use unmkpp to return the piecewise polynomial details to MATLAB.

    • In MATLAB, use mkpp to create the pp structure.

pol2cart

polyarea

ppval

The size of output v does not match MATLAB when both of the following statements are true:

  • The input x is a variable-size array that is not a variable-length vector.

  • x becomes a row vector at run time.

The code generation software does not remove the singleton dimensions. However, MATLAB might remove singleton dimensions.

For example, suppose that x is a :4-by-:5 array and ppval(pp,0) returns a 2-by-3 fixed-size array. v has size 2-by-3-by-:4-by-:5. At run time, suppose that, size(x,1) =1 and size (x,2) = 5. In the generated code, the size(v) is [2,3,1,5]. In MATLAB, the size is [2,3,5].

rectint

sph2cart

spline

  • Input x must be strictly increasing.

  • Does not remove Y entries with NaN values.

  • Does not report an error for infinite endslopes in Y.

  • If you generate code for the pp = spline(x,Y) syntax, you cannot input pp to the ppval function in MATLAB. To create a MATLAB pp structure from a pp structure created by the code generation software:

    • In code generation, use unmkpp to return the piecewise polynomial details to MATLAB.

    • In MATLAB, use mkpp to create the pp structure.

unmkpp

  • pp must be a valid piecewise polynomial structure created by mkpp, spline, or pchip in MATLAB or by the code generation software.

  • Does not support pp structures created by interp1 in MATLAB.

Linear Algebra in MATLAB

FunctionRemarks and Limitations

linsolve

  • The option structure must be a constant.

  • Supports only a scalar option structure input. It does not support arrays of option structures.

  • Only optimizes these cases:

    • UT

    • LT

    • UHESS = true (the TRANSA can be either true or false)

    • SYM = true and POSDEF = true

    Other options are equivalent to using mldivide.

null

  • Might return a different basis than MATLAB

  • Does not support rational basis option (second input)

orth

  • Can return a different basis than MATLAB

rsf2csf

schur

Can return a different Schur decomposition in generated code than in MATLAB.

sqrtm

Logical and Bit-Wise Operations in MATLAB

FunctionRemarks and Limitations

and

bitand

bitcmp

bitget

bitor

bitset

bitshift

bitxor

not

or

xor

MATLAB Compiler

C and C++ code generation for the following functions requires the MATLAB Compiler™ software.

Function

Remarks and Limitations

isdeployed

  • Returns true and false as appropriate for MEX and SIM targets

  • Returns false for other targets

ismcc

  • Returns true and false as appropriate for MEX and SIM targets.

  • Returns false for other targets.

Matrices and Arrays in MATLAB

Function

Remarks and Limitations

abs

all

Variable Sizing Restrictions for Code Generation of Toolbox Functions

angle

any

Variable Sizing Restrictions for Code Generation of Toolbox Functions

blkdiag

bsxfun

Variable Sizing Restrictions for Code Generation of Toolbox Functions

cat

circshift

colon

  • Does not accept complex inputs.

  • Does not accept a logical interval,i.

  • Does not accept vector inputs.

  • Inputs must be constants.

  • Uses single-precision arithmetic to produce single-precision results.

compan

cond

Variable Sizing Restrictions for Code Generation of Toolbox Functions

cov

Variable Sizing Restrictions for Code Generation of Toolbox Functions

cross

cumprod

  • Logical inputs are not supported. Cast input to double first.

cumsum

  • Logical inputs are not supported. Cast input to double first.

det

diag

  • If supplied, the argument representing the order of the diagonal matrix must be a real and scalar integer value.

  • For variable-size inputs that are variable-length vectors (1-by-: or :-by-1), diag:

    • Treats the input as a vector input.

    • Returns a matrix with the given vector along the specified diagonal.

  • For variable-size inputs that are not variable-length vectors, diag:

    • Treats the input as a matrix.

    • Does not support inputs that are vectors at run time.

    • Returns a variable-length vector.

    If the input is variable-size (:m-by-:n) and has shape 0-by-0 at run time, the output is 0-by-1 not 0-by-0. However, if the input is a constant size 0-by-0, the output is [].

  • For variable-size inputs that are not variable-length vectors (1-by-: or :-by-1), diag treats the input as a matrix from which to extract a diagonal vector. This behavior occurs even if the input array is a vector at run time. To force diag to build a matrix from variable-size inputs that are not 1-by-: or :-by-1, use:

    • diag(x(:)) instead of diag(x)

    • diag(x(:),k) instead of diag(x,k)

  • Variable Sizing Restrictions for Code Generation of Toolbox Functions

diff

dot

eig

  • QZ algorithm used in all cases, whereas MATLAB might use different algorithms for different inputs. Consequently, V might represent a different basis of eigenvectors, and the eigenvalues in D might not be in the same order as in MATLAB.

  • With one input, [V,D] = eig(A), the results will be similar to those obtained using [V,D] = eig(A,eye(size(A)),'qz') in MATLAB, except that for code generation, the columns of V are normalized.

  • Options 'balance', 'nobalance' are not supported for the standard eigenvalue problem, and 'chol' is not supported for the symmetric generalized eigenvalue problem.

  • Outputs are of complex type.

eye

classname must be a built-in MATLAB numeric type. Does not invoke the static eye method for other classes. For example, eye(m, n, 'myclass') does not invoke myclass.eye(m,n).

false

  • Dimensions must be real, nonnegative, integers.

find

  • Issues an error if a variable-sized input becomes a row vector at run time.

      Note:   This limitation does not apply when the input is scalar or a variable-length row vector.

  • For variable-sized inputs, the shape of empty outputs, 0-by-0, 0-by-1, or 1-by-0, depends on the upper bounds of the size of the input. The output might not match MATLAB when the input array is a scalar or [] at run time. If the input is a variable-length row vector, the size of an empty output is 1-by-0, otherwise it is 0-by-1.

flip

flipdim

    Note:   flipdim will be removed in a future release. Use flip instead.

fliplr

flipud

full

hadamard

hankel

hilb

ind2sub

inv

Singular matrix inputs can produce nonfinite values that differ from MATLAB results.

invhilb

ipermute

Variable Sizing Restrictions for Code Generation of Toolbox Functions

iscolumn

isempty

isequal

isequaln

isfinite

isfloat

isinf

isinteger

islogical

ismatrix

isnan

isrow

issparse

isvector

kron

length

linspace

logspace

lu

magic

Variable Sizing Restrictions for Code Generation of Toolbox Functions

max

min

ndgrid

ndims

nnz

nonzeros

norm

normest

numel

ones

  • Dimensions must be real, nonnegative integers.

  • The input optimfun must be a function supported for code generation.

pascal

permute

Variable Sizing Restrictions for Code Generation of Toolbox Functions

pinv

planerot

Variable Sizing Restrictions for Code Generation of Toolbox Functions

prod

qr

rand

randi

  • classname must be a built-in MATLAB numeric type. Does not invoke the static randi method for other classes. For example, randi(imax,sz,'myclass') does not invoke myclass.randi(imax,sz).

randn

randperm

rank

rcond

repmat

reshape

v

rng

  • For library code generation targets, executable code generation targets, and MEX targets with extrinsic calls disabled:

    • Does not support the 'shuffle' input.

    • For the generator input, supports 'twister', 'v4', and 'v5normal'.

    For these targets, the output of s=rng in the generated code differs from the MATLAB output. You cannot return the output of s=rng from the generated code and pass it to rng in MATLAB.

  • For MEX targets, if extrinsic calls are enabled, you cannot access the data in the structure returned by rng.

rosser

rot90

shiftdim

sign

size

sort

If the input is a complex type, sort orders the output according to absolute value. When x is a complex type that has all zero imaginary parts, use sort(real(x)) to compute the sort order for real types. See Code Generation for Complex Data.

sortrows

If the input is a complex type, sortrows orders the output according to absolute value. When x is a complex type that has all zero imaginary parts, use sortrows(real(x)) to compute the sort order for real types. See Code Generation for Complex Data.

squeeze

sub2ind

subspace

sum

toeplitz

trace

tril

  • If supplied, the argument representing the order of the diagonal matrix must be a real and scalar integer value.

triu

  • If supplied, the argument representing the order of the diagonal matrix must be a real and scalar integer value.

true

  • Dimensions must be real, nonnegative, integers.

vander

wilkinson

zeros

  • Dimensions must be real, nonnegative, integers.

Nonlinear Numerical Methods in MATLAB

Function

Remarks and Limitations

quad2d

  • Generates a warning if the size of the internal storage arrays is not large enough. If a warning occurs, a possible workaround is to divide the region of integration into pieces and sum the integrals over each piece.

quadgk

Numerical Integration and Differentiation in MATLAB

Function

Remarks and Limitations

cumtrapz

del2

diff

  • If supplied, the arguments representing the number of times to apply diff and the dimension along which to calculate the difference must be constants.

gradient

trapz

Optimization Functions in MATLAB

Function

Remarks and Limitations

fminsearch

  • Ignores the Display option. Does not print status information during execution. Check the exitflag output for the exit condition.

  • The output structure does not include the algorithm or message fields.

  • Ignores the OutputFcn and PlotFcns options.

fzero

  • The first argument must be a function handle. Does not support structure, inline function, or string inputs for the first argument.

  • Supports up to three output arguments. Does not support the fourth output argument (the output structure).

optimget

Input parameter names must be constant.

optimset

  • Does not support the syntax that has no input or output arguments:

    optimset

  • Functions specified in the options must be supported for code generation.

  • The fields of the options structure oldopts must be fixed-size fields.

  • For code generation, optimization functions ignore the Display option.

  • Does not support the additional options in an options structure created by the Optimization Toolbox™ optimset function. If an input options structure includes the additional Optimization Toolbox options, the output structure does not include them.

Phased Array System Toolbox

C and C++ code generation for the following functions requires the Phased Array System Toolbox™ software.

NameRemarks and Limitations
Antenna and Microphone Elements

aperture2gain

Does not support variable-size inputs.

azel2phithetapat

Does not support variable-size inputs.

azel2uvpat

Does not support variable-size inputs.

circpol2pol

Does not support variable-size inputs.

gain2aperture

Does not support variable-size inputs.

phased.CosineAntennaElement
phased.CrossedDipoleAntennaElement
phased.CustomAntennaElement
phased.CustomMicrophoneElement
phased.IsotropicAntennaElement
phased.OmnidirectionalMicrophoneElement
phased.ShortDipoleAntennaElement

phitheta2azelpat

Does not support variable-size inputs.

phitheta2uvpat

Does not support variable-size inputs.

pol2circpol

Does not support variable-size inputs.

polellip

Does not support variable-size inputs.

polloss

Does not support variable-size inputs.

polratio

Does not support variable-size inputs.

polsignature

  • Does not support variable-size inputs.

  • Supported only when output arguments are specified.

stokes

  • Does not support variable-size inputs.

  • Supported only when output arguments are specified.

uv2azelpat

Does not support variable-size inputs.

uv2phithetapat

Does not support variable-size inputs.

Array Geometries and Analysis

az2broadside

Does not support variable-size inputs.

broadside2az

Does not support variable-size inputs.

phased.ArrayGain
  • Does not support arrays containing polarized antenna elements, that is, the phased.ShortDipoleAntennaElement or phased.CrossedDipoleAntennaElement antennas.

  • Code Generation.

phased.ArrayResponseCode Generation.
phased.ConformalArray
phased.ElementDelayCode Generation.
phased.PartitionedArray
phased.ReplicatedSubarray
phased.SteeringVectorSee Code Generation.
phased.ULA
phased.URA
Signal Radiation and Collection
phased.CollectorCode Generation.
phased.RadiatorCode Generation.
phased.WidebandCollector

sensorsig

Does not support variable-size inputs.

Waveforms

ambgfun

Does not support variable-size inputs.

phased.FMCWWaveformCode Generation.
phased.LinearFMWaveformCode Generation.
phased.PhaseCodedWaveformCode Generation.
phased.RectangularWaveformCode Generation.
phased.SteppedFMWaveformCode Generation.

range2bw

Does not support variable-size inputs.

range2time

Does not support variable-size inputs.

time2range

Does not support variable-size inputs.

unigrid

Does not support variable-size inputs.

Transmitters and Receivers

delayseq

Does not support variable-size inputs.

noisepow

Does not support variable-size inputs.

phased.ReceiverPreampCode Generation.
phased.TransmitterCode Generation.

systemp

Does not support variable-size inputs.

Beamforming

cbfweights

Does not support variable-size inputs.

lcmvweights

Does not support variable-size inputs.

mvdrweights

Does not support variable-size inputs.

phased.FrostBeamformer
phased.LCMVBeamformerCode Generation.
phased.MVDRBeamformerCode Generation.
phased.PhaseShiftBeamformerCode Generation.
phased.SteeringVectorCode Generation.
phased.SubbandPhaseShiftBeamformerCode Generation.
phased.TimeDelayBeamformer
phased.TimeDelayLCMVBeamformer

sensorcov

Does not support variable-size inputs.

steervec

Does not support variable-size inputs.

Direction of Arrival (DOA) Estimation

aictest

Does not support variable-size inputs.

espritdoa

Does not support variable-size inputs.

mdltest

Does not support variable-size inputs.

phased.BeamscanEstimatorCode Generation.
phased.BeamscanEstimator2DCode Generation.
phased.BeamspaceESPRITEstimatorCode Generation.
phased.ESPRITEstimatorCode Generation.
phased.MVDREstimatorCode Generation.
phased.MVDREstimator2DCode Generation.
phased.RootMUSICEstimatorCode Generation.
phased.RootWSFEstimatorCode Generation.
phased.SumDifferenceMonopulseTrackerCode Generation.
phased.SumDifferenceMonopulseTracker2DCode Generation.

rootmusicdoa

Does not support variable-size inputs.

spsmooth

Does not support variable-size inputs.

Space-Time Adaptive Processing (STAP)

dopsteeringvec

Does not support variable-size inputs.

phased.ADPCACancellerCode Generation.
phased.AngleDopplerResponseCode Generation.
phased.DPCACancellerCode Generation.
phased.STAPSMIBeamformerCode Generation.

val2ind

Does not support variable-size inputs.

Signal Propagation and Environment

billingsleyicm

Does not support variable-size inputs.

depressionang

Does not support variable-size inputs.

effearthradius

Does not support variable-size inputs.

fspl

Does not support variable-size inputs.

grazingang

Does not support variable-size inputs.

horizonrange

Does not support variable-size inputs.

phased.BarrageJammerCode Generation.
phased.ConstantGammaClutterCode Generation.
phased.FreeSpace
phased.RadarTargetCode Generation.

physconst

Does not support variable-size inputs.

surfacegamma

Does not support variable-size inputs.

surfclutterrcs

Does not support variable-size inputs.

Detection and System Analysis

albersheim

Does not support variable-size inputs.

beat2range

Does not support variable-size inputs.

dechirp

Does not support variable-size inputs.

npwgnthresh

Does not support variable-size inputs.

phased.CFARDetectorCode Generation.
phased.MatchedFilter
phased.RangeDopplerResponse
  • The CustomRangeWindow and the CustomDopplerWindow properties are not supported.

  • Code Generation.

phased.StretchProcessorCode Generation.
phased.TimeVaryingGainCode Generation.

pulsint

Does not support variable-size inputs.

radareqpow

Does not support variable-size inputs.

radareqrng

Does not support variable-size inputs.

radareqsnr

Does not support variable-size inputs.

radarvcd

Does not support variable-size inputs.

range2beat

Does not support variable-size inputs.

rdcoupling

Does not support variable-size inputs.

rocpfa

  • Does not support variable-size inputs.

  • The NonfluctuatingNoncoherent signal type is not supported.

rocsnr

  • Does not support variable-size inputs.

  • The NonfluctuatingNoncoherent signal type is not supported.

shnidman

Does not support variable-size inputs.

stretchfreq2rng

Does not support variable-size inputs.

Motion Modeling and Coordinate Systems

azel2phitheta

Does not support variable-size inputs.

azel2uv

Does not support variable-size inputs.

azelaxes

Does not support variable-size inputs.

cart2sphvec

Does not support variable-size inputs.

dop2speed

Does not support variable-size inputs.

global2localcoord

Does not support variable-size inputs.

local2globalcoord

Does not support variable-size inputs.

phased.PlatformCode Generation.

phitheta2azel

Does not support variable-size inputs.

phitheta2uv

Does not support variable-size inputs.

radialspeed

Does not support variable-size inputs.

rangeangle

Does not support variable-size inputs.

rotx

Does not support variable-size inputs.

roty

Does not support variable-size inputs

rotz

Does not support variable-size inputs.

speed2dop

Does not support variable-size inputs.

sph2cartvec

Does not support variable-size inputs.

uv2azel

Does not support variable-size inputs.

uv2phitheta

Does not support variable-size inputs.

Polynomials in MATLAB

Function

Remarks and Limitations

poly

polyder

The output can contain fewer NaNs than the MATLAB output. However, if the input contains a NaN, the output contains at least one NaN.

polyfit

Variable Sizing Restrictions for Code Generation of Toolbox Functions

polyint

polyval

polyvalm

roots

  • Output is variable size.

  • Output is complex.

  • Roots are not always in the same order as MATLAB.

  • Roots of poorly conditioned polynomials do not always match MATLAB.

Programming Utilities in MATLAB

Function

Remarks and Limitations

mfilename

Relational Operators in MATLAB

Function

Remarks and Limitations

eq

ge

gt

le

lt

ne

Rounding and Remainder Functions in MATLAB

Function

Remarks and Limitations

ceil

fix

floor

mod

  • Performs the arithmetic using the output class. Results might not match MATLAB due to differences in rounding errors.

    If one of the inputs has type int64 or uint64, then both inputs must have the same type.

rem

  • Performs the arithmetic using the output class. Results might not match MATLAB due to differences in rounding errors.

  • If one of the inputs has type int64 or uint64, then both inputs must have the same type.

round

Set Operations in MATLAB

Function

Remarks and Limitations

intersect

  • When you do not specify the 'rows' option:

    • Inputs A and B must be vectors. If you specify the 'legacy' option, inputs A and B must be row vectors.

    • The first dimension of a variable-size row vector must have fixed length 1. The second dimension of a variable-size column vector must have fixed length 1.

    • The input [] is not supported. Use a 1-by-0 or 0-by-1 input, for example, zeros(1,0), to represent the empty set.

    • If you specify the 'legacy' option, empty outputs are row vectors, 1-by-0, never 0-by-0.

  • When you specify both the 'legacy' option and the 'rows' option, the outputs ia and ib are column vectors. If these outputs are empty, they are 0-by-1, never 0-by-0, even if the output C is 0-by-0.

  • When the setOrder is 'sorted' or when you specify the 'legacy' option, the inputs must already be sorted in ascending order. The first output, C, is sorted in ascending order.

  • Complex inputs must be single or double.

  • When one input is complex and the other input is real, do one of the following:

    • Set setOrder to 'stable'.

    • Sort the real input in complex ascending order (by absolute value). Suppose the real input is x. Use sort(complex(x))or sortrows(complex(x)).

ismember

  • The second input, B, must be sorted in ascending order.

  • Complex inputs must be single or double.

issorted

Variable Sizing Restrictions for Code Generation of Toolbox Functions

setdiff

  • When you do not specify the 'rows' option:

    • Inputs A and B must be vectors. If you specify the 'legacy' option, inputs A and B must be row vectors.

    • The first dimension of a variable-size row vector must have fixed length 1. The second dimension of a variable-size column vector must have fixed length 1.

    • Do not use [] to represent the empty set. Use a 1-by-0 or 0-by-1 input, for example, zeros(1,0), to represent the empty set.

    • If you specify the 'legacy' option, empty outputs are row vectors, 1-by-0, never 0-by-0.

  • When you specify both the 'legacy' and 'rows' options, the output ia is a column vector. If ia is empty, it is 0-by-1, never 0-by-0, even if the output C is 0-by-0.

  • When the setOrder is 'sorted' or when you specify the 'legacy' option, the inputs must already be sorted in ascending order. The first output, C, is sorted in ascending order.

  • Complex inputs must be single or double.

  • When one input is complex and the other input is real, do one of the following:

    • Set setOrder to 'stable'.

    • Sort the real input in complex ascending order (by absolute value). Suppose the real input is x. Use sort(complex(x))or sortrows(complex(x)).

setxor

  • When you do not specify the 'rows' option:

    • Inputs A and B must be vectors with the same orientation. If you specify the 'legacy' option, inputs A and B must be row vectors.

    • The first dimension of a variable-size row vector must have fixed length 1. The second dimension of a variable-size column vector must have fixed length 1.

    • The input [] is not supported. Use a 1-by-0 or 0-by-1 input, for example , zeros(1,0), to represent the empty set.

    • If you specify the 'legacy' option, empty outputs are row vectors, 1-by-0, never 0-by-0.

  • When you specify both the 'legacy' option and the 'rows' option, the outputs ia and ib are column vectors. If these outputs are empty, they are 0-by-1, never 0-by-0, even if the output C is 0-by-0.

  • When the setOrder is 'sorted' or when you specify the 'legacy' flag, the inputs must already be sorted in ascending order. The first output, C, is sorted in ascending order.

  • Complex inputs must be single or double.

  • When one input is complex and the other input is real, do one of the following:

    • Set setOrder to 'stable'.

    • Sort the real input in complex ascending order (by absolute value). Suppose the real input is x. Use sort(complex(x))or sortrows(complex(x)).

union

  • When you do not specify the 'rows' option:

    • Inputs A and B must be vectors with the same orientation. If you specify the 'legacy' option, inputs A and B must be row vectors.

    • The first dimension of a variable-size row vector must have fixed length 1. The second dimension of a variable-size column vector must have fixed length 1.

    • The input [] is not supported. Use a 1-by-0 or 0-by-1 input, for example , zeros(1,0), to represent the empty set.

    • If you specify the 'legacy' option, empty outputs are row vectors, 1-by-0, never 0-by-0.

  • When you specify both the 'legacy' option and the 'rows' option, the outputs ia and ib are column vectors. If these outputs are empty, they are 0-by-1, never 0-by-0, even if the output C is 0-by-0.

  • When the setOrder is 'sorted' or when you specify the 'legacy' option, the inputs must already be sorted in ascending order. The first output, C, is sorted in ascending order.

  • Complex inputs must be single or double.

  • When one input is complex and the other input is real, do one of the following:

    • Set setOrder to 'stable'.

    • Sort the real input in complex ascending order (by absolute value). Suppose the real input is x. Use sort(complex(x))or sortrows(complex(x)).

unique

  • When you do not specify the'rows' option:

    • The input A must be a vector. If you specify the 'legacy' option, the input A must be a row vector.

    • The first dimension of a variable-size row vector must have fixed length 1. The second dimension of a variable-size column vector must have fixed length 1.

    • The input [] is not supported. Use a 1-by-0 or 0-by-1 input, for example, zeros(1,0), to represent the empty set.

    • If you specify the 'legacy' option, empty outputs are row vectors, 1-by-0, never 0-by-0.

  • When you specify both the 'rows' option and the 'legacy'option, outputs ia and ic are column vectors. If these outputs are empty, they are 0-by-1, even if the output C is 0-by-0.

  • When the setOrder is 'sorted' or when you specify the 'legacy' option, the input A must already be sorted in ascending order. The first output, C, is sorted in ascending order.

  • Complex inputs must be single or double.

Signal Processing in MATLAB

FunctionRemarks and Limitations

chol

conv

fft

fft2

  • Length of input matrix dimensions must each be a power of 2.

fftn

  • Length of input matrix dimensions must each be a power of 2.

fftshift

filter

  • If supplied, dim must be a constant.

  • v

freqspace

ifft

ifft2

  • Length of input matrix dimensions must each be a power of 2.

  • Does not support the 'symmetric' option.

ifftn

  • Length of input matrix dimensions must each be a power of 2.

  • Does not support the 'symmetric' option.

ifftshift

svd

Uses a different SVD implementation than MATLAB. Because the singular value decomposition is not unique, left and right singular vectors might differ from those computed by MATLAB.

zp2tf

Signal Processing Toolbox

C and C++ code generation for the following functions requires the Signal Processing Toolbox™ software. These functions do not support variable-size inputs, you must define the size and type of the function inputs. For more information, see Specifying Inputs in Code Generation from MATLAB .

    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.

Special Values in MATLAB

Function

Remarks and Limitations

eps

  • Supported for scalar fixed-point signals only.

  • Supported for scalar, vector, and matrix, fi single and fi double signals.

inf

  • Dimensions must be real, nonnegative, integers.

intmax

intmin

NaN or nan

  • Dimensions must be real, nonnegative, integers.

pi

realmax

realmin

Specialized Math in MATLAB

Function

Remarks and Limitations

beta

betainc

Always returns a complex result.

betaincinv

Always returns a complex result.

betaln

ellipke

erf

erfc

erfcinv

erfcx

erfinv

expint

gamma

gammainc

Output is always complex.

gammaincinv

Output is always complex.

gammaln

psi

Statistics in MATLAB

Function

Remarks and Limitations

corrcoef

  • Row-vector input is only supported when the first two inputs are vectors and nonscalar.

mean

  • Does not support the type parameter.

median

mode

std

Variable Sizing Restrictions for Code Generation of Toolbox Functions

var

Statistics Toolbox

C and C++ code generation for the following functions requires the Statistics Toolbox™ software.

Function

Remarks and Limitations

betacdf

betainv

betapdf

betarnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

betastat

binocdf

binoinv

binopdf

binornd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

binostat

cdf

chi2cdf

chi2inv

chi2pdf

chi2rnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

chi2stat

evcdf

evinv

evpdf

evrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

evstat

expcdf

expinv

exppdf

exprnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

expstat

fcdf

finv

fpdf

frnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

fstat

gamcdf

gaminv

gampdf

gamrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

gamstat

geocdf

geoinv

geomean

geopdf

geornd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

geostat

gevcdf

gevinv

gevpdf

gevrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

gevstat

gpcdf

gpinv

gppdf

gprnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

gpstat

harmmean

hygecdf

hygeinv

hygepdf

hygernd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

hygestat

icdf

iqr

kurtosis

logncdf

logninv

lognpdf

lognrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

lognstat

mad

Input dim cannot be empty.

mnpdf

Input dim cannot be empty.

moment

If order is nonintegral and X is real, use moment(complex(X), order).

nancov

If the input is variable-size and is [] at run time, returns [] not NaN.

nanmax

nanmean

nanmedian

nanmin

nanstd

nansum

nanvar

nbincdf

nbininv

nbinpdf

nbinrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

nbinstat

ncfcdf

ncfinv

ncfpdf

ncfrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

ncfstat

nctcdf

nctinv

nctpdf

nctrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

nctstat

ncx2cdf

ncx2rnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

ncx2stat

normcdf

norminv

normpdf

normrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

normstat

pdf

poisscdf

poissinv

poisspdf

poissrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

poisstat

prctile

  • Automatic dimension restriction

  • If the output Y is a vector, the orientation of Y differs from MATLAB when all of the following are true:

    • You do not supply the dim input.

    • X is a variable-size array.

    • X is not a variable-length vector.

    • X is a vector at run time.

    • The orientation of the vector X does not match the orientation of the vector p.

    In this case, the output Y matches the orientation of X not the orientation of p.

quantile

randg

random

raylcdf

raylinv

raylpdf

raylrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

raylstat

skewness

tcdf

tinv

tpdf

trnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

tstat

unidcdf

unidinv

unidpdf

unidrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

unidstat

unifcdf

unifinv

unifpdf

unifrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

unifstat

wblcdf

wblinv

wblpdf

wblrnd

Can return a different sequence of numbers than MATLAB if either of the following is true:

  • The output is nonscalar.

  • An input parameter is invalid for the distribution.

wblstat

zscore

String Functions in MATLAB

Function

Remarks and Limitations

bin2dec

  • Does not match MATLAB when the input is empty.

bitmax

blanks

char

deblank

  • Supports only inputs from the char class.

  • Input values must be in the range 0-127.

dec2bin

  • If input d is double, d must be less than 2^52.

  • If input d is single, d must be less than 2^23.

  • Unless you specify input n to be constant and n is large enough that the output has a fixed number of columns regardless of the input values, this function requires variable-sizing support. Without variable-sizing support, n must be at least 52 for double, 23 for single, 16 for char, 32 for int32, 16 for int16, and so on.

dec2hex

  • If input d is double, d must be less than 2^52.

  • If input d is single, d must be less than 2^23.

  • Unless you specify input n to be constant and n is large enough that the output has a fixed number of columns regardless of the input values, this function requires variable-sizing support. Without variable-sizing support, n must be at least 13 for double, 6 for single, 4 for char, 8 for int32, 4 for int16, and so on.

hex2dec

hex2num

  • For n = hex2num(S), size(S,2) <= length(num2hex(0))

ischar

isletter

  • Input values from the char class must be in the range 0-127

isspace

  • Input values from the char class must be in the range 0–127.

isstrprop

  • Supports only inputs from char and integer classes.

  • Input values must be in the range 0-127.

lower

  • Supports only char inputs.

  • Input values must be in the range 0-127.

num2hex

strcmp

strcmpi
  • Input values from the char class must be in the range 0-127.

strfind
  • Does not support cell arrays.

  • If pattern does not exist in str, returns zeros(1,0) not []. To check for an empty return, use isempty.

  • Inputs must be character row vectors.

strjust

strncmp

strncmpi

  • Input values from the char class must be in the range 0-127.

strrep

  • Does not support cell arrays.

  • If oldSubstr does not exist in origStr, returns blanks(0). To check for an empty return, use isempty.

  • Inputs must be character row vectors.

strtok

strtrim

  • Supports only inputs from the char class.

  • Input values must be in the range 0-127.

upper

  • Supports only char inputs.

  • Input values must be in the range 0-127.

Structures in MATLAB

Function

Remarks and Limitations

isfield

  • Does not support cell input for second argument

isstruct

struct

Trigonometry in MATLAB

Function

Remarks and Limitations

acos

  • Generates an error during simulation and returns NaN in generated code when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

acosd

acosh

  • Generates an error during simulation and returns NaN in generated code when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

acot

acotd

acoth

acsc

acscd

acsch

asec

asecd

asech

asin

  • Generates an error during simulation and returns NaN in generated code when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

asind

asinh

atan

atan2

atan2d

atand

atanh

Generates an error during simulation and returns NaN in generated code when the input value x is real, but the output should be complex. To get the complex result, make the input value complex by passing in complex(x).

cos

cosd

cosh

cot

cotd

coth

csc

cscd

csch

hypot

sec

secd

sech

sin

sind

sinh

tan

tand

tanh

Was this topic helpful?