Code Generation Support, Usage Notes, and Limitations

Generating C/C++ code requires MATLAB® Coder™. MATLAB Coder generates C/C++ code for the Statistics and Machine Learning Toolbox™ functions that support code generation, given these conditions:

  • You cannot call any function at the top level when generating code by using codegen. Instead, call the function within an entry-point function, and then generate code from the entry-point function. The entry-point function, also known as the top-level or primary function, is a function you define for code generation. All functions within the entry-point function must support code generation.

  • The MATLAB Coder limitations also apply to Statistics and Machine Learning Toolbox for code generation. For details, see MATLAB Language Features Supported for C/C++ Code Generation (MATLAB Coder).

  • Code generation in Statistics and Machine Learning Toolbox does not support sparse matrices, categorical arrays and tables.

To learn about code generation, see Introduction to Code Generation.

This table lists the Statistics and Machine Learning Toolbox functions that support code generation.

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

betacdf

Beta cumulative distribution function

BetaDistribution*

Beta probability distribution object

betafit

Beta parameter estimates

betainv

Beta inverse cumulative distribution function

betalike

Beta negative log-likelihood

betapdf

Beta probability density function

betarnd*

Beta random numbers

betastat

Beta mean and variance

binocdf

Binomial cumulative distribution function

binoinv

Binomial inverse cumulative distribution function

binopdf

Binomial probability density function

binornd*

Random numbers from binomial distribution

binostat

Binomial mean and variance

categorical*

Array that contains values assigned to categories

cdf*

Cumulative distribution function

chi2cdf

Chi-square cumulative distribution function

chi2inv

Chi-square inverse cumulative distribution function

chi2pdf

Chi-square probability density function

chi2rnd*

Chi-square random numbers

chi2stat

Chi-square mean and variance

ClassificationBaggedEnsemble*

Classification ensemble grown by resampling

ClassificationDiscriminant*

Discriminant analysis classification

ClassificationECOC*

Multiclass model for support vector machines (SVMs) and other classifiers

ClassificationEnsemble*

Ensemble classifier

ClassificationKNN*

k-nearest neighbor classification

ClassificationLinear*

Linear model for binary classification of high-dimensional data

ClassificationNaiveBayes*

Naive Bayes classification

ClassificationSVM*

Support vector machine (SVM) for one-class and binary classification

ClassificationTree*

Binary decision tree for classification

CompactClassificationDiscriminant*

Compact discriminant analysis class

CompactClassificationECOC*

Compact multiclass model for support vector machines (SVMs) and other classifiers

CompactClassificationEnsemble*

Compact classification ensemble class

CompactClassificationNaiveBayes*

Compact naive Bayes classifier

CompactClassificationSVM*

Compact support vector machine (SVM) for one-class and binary classification

CompactClassificationTree*

Compact classification tree

CompactGeneralizedLinearModel*

Compact generalized linear regression model class

CompactLinearModel*

Compact linear regression model

CompactRegressionEnsemble*

Compact regression ensemble class

CompactRegressionGP*

Compact Gaussian process regression model class

CompactRegressionSVM*

Compact support vector machine regression model

CompactRegressionTree*

Compact regression tree

coxphfit*

Cox proportional hazards regression

ecdf*

Empirical cumulative distribution function

evcdf

Extreme value cumulative distribution function

evfit

Extreme value parameter estimates

evinv

Extreme value inverse cumulative distribution function

evpdf

Extreme value probability density function

evrnd*

Extreme value random numbers

evstat

Extreme value mean and variance

ExhaustiveSearcher*

Create exhaustive nearest neighbor searcher

expcdf

Exponential cumulative distribution function

expfit

Exponential parameter estimates

expinv

Exponential inverse cumulative distribution function

ExponentialDistribution*

Exponential probability distribution object

exppdf

Exponential probability density function

exprnd*

Exponential random numbers

expstat

Exponential mean and variance

ExtremeValueDistribution*

Extreme value probability distribution object

fcdf

F cumulative distribution function

finv

F inverse cumulative distribution function

fitdist*

Fit probability distribution object to data

fpdf

F probability density function

frnd*

F random numbers

fstat

F mean and variance

gamcdf

Gamma cumulative distribution function

gaminv

Gamma inverse cumulative distribution function

gampdf

Gamma probability density function

gamrnd*

Gamma random numbers

gamstat

Gamma mean and variance

GeneralizedLinearModel*

Generalized linear regression model class

GeneralizedParetoDistribution*

Normal probability distribution object

geocdf

Geometric cumulative distribution function

geoinv

Geometric inverse cumulative distribution function

geomean*

Geometric mean

geopdf

Geometric probability density function

geornd*

Geometric random numbers

geostat

Geometric mean and variance

gevcdf

Generalized extreme value cumulative distribution function

gevinv

Generalized extreme value inverse cumulative distribution function

gevpdf

Generalized extreme value probability density function

gevrnd*

Generalized extreme value random numbers

gevstat

Generalized extreme value mean and variance

glmval*

Generalized linear model values

gpcdf

Generalized Pareto cumulative distribution function

gpinv

Generalized Pareto inverse cumulative distribution function

gppdf

Generalized Pareto probability density function

gprnd*

Generalized Pareto random numbers

gpstat

Generalized Pareto mean and variance

grp2idx*

Create index vector from grouping variable

harmmean*

Harmonic mean

hygecdf

Hypergeometric cumulative distribution function

hygeinv

Hypergeometric inverse cumulative distribution function

hygepdf

Hypergeometric probability density function

hygernd*

Hypergeometric random numbers

hygestat

Hypergeometric mean and variance

icdf*

Inverse cumulative distribution function

iqr*

Interquartile range

KDTreeSearcher*

Create Kd-tree nearest neighbor searcher

kmeans*

k-means clustering

knnsearch*

Find k-nearest neighbors using input data

knnsearch*

Find k-nearest neighbors using searcher object

ksdensity*

Kernel smoothing function estimate for univariate and bivariate data

kurtosis*

Kurtosis

LinearModel*

Linear regression model

loadCompactModel

(To be removed) Reconstruct model object from saved model for code generation

loadLearnerForCoder*

Reconstruct model object from saved model for code generation

logncdf

Lognormal cumulative distribution function

lognfit

Lognormal parameter estimates

logninv

Lognormal inverse cumulative distribution function

LognormalDistribution*

Lognormal probability distribution object

lognpdf

Lognormal probability density function

lognrnd*

Lognormal random numbers

lognstat

Lognormal mean and variance

mad*

Mean or median absolute deviation

mean*

Mean of probability distribution

median*

Median of probability distribution

mnpdf

Multinomial probability density function

moment*

Central moment

mvksdensity*

Kernel smoothing function estimate for multivariate data

nancov*

Covariance ignoring NaN values

nanmax*

Maximum, ignoring NaN values

nanmean*

Mean, ignoring NaN values

nanmedian*

Median, ignoring NaN values

nanmin*

Minimum, ignoring NaN values

nanstd*

Standard deviation, ignoring NaN values

nansum*

Sum, ignoring NaN values

nanvar*

Variance, ignoring NaN values

nbincdf

Negative binomial cumulative distribution function

nbininv

Negative binomial inverse cumulative distribution function

nbinpdf

Negative binomial probability density function

nbinrnd*

Negative binomial random numbers

nbinstat

Negative binomial mean and variance

ncfcdf

Noncentral F cumulative distribution function

ncfinv

Noncentral F inverse cumulative distribution function

ncfpdf

Noncentral F probability density function

ncfrnd*

Noncentral F random numbers

ncfstat

Noncentral F mean and variance

nctcdf

Noncentral t cumulative distribution function

nctinv

Noncentral t inverse cumulative distribution function

nctpdf

Noncentral t probability density function

nctrnd*

Noncentral t random numbers

nctstat

Noncentral t mean and variance

ncx2cdf

Noncentral chi-square cumulative distribution function

ncx2rnd*

Noncentral chi-square random numbers

ncx2stat

Noncentral chi-square mean and variance

normcdf

Normal cumulative distribution function

normfit

Normal parameter estimates

norminv

Normal inverse cumulative distribution function

normpdf

Normal probability density function

normrnd*

Normal random numbers

normstat

Normal mean and variance

pca*

Principal component analysis of raw data

pdf*

Probability density function

pdist*

Pairwise distance between pairs of observations

pdist2*

Pairwise distance between two sets of observations

pearsrnd*

Pearson system random numbers

poisscdf

Poisson cumulative distribution function

poissinv

Poisson inverse cumulative distribution function

poisspdf

Poisson probability density function

poissrnd*

Random numbers from Poisson distribution

poisstat

Poisson mean and variance

prctile*

Percentiles of a data set

predict*

Predict responses of linear regression model

predict*

Classify observations using multiclass error-correcting output codes (ECOC) model

predict*

Classify observations using support vector machine (SVM) classifier

predict*

Predict labels using discriminant analysis classification model

predict*

Predict response of Gaussian process regression model

predict*

Predict labels using classification tree

predict*

Predict labels for linear classification models

predict*

Predict labels using k-nearest neighbor classification model

predict*

Predict response of linear regression model

predict*

Predict response of generalized linear regression model

predict*

Predict responses using ensemble of regression models

predict*

Predict labels using naive Bayes classification model

predict*

Predict responses using regression tree

predict*

Classify observations using ensemble of classification models

predict*

Predict responses using support vector machine regression model

quantile*

Quantiles of a data set

randg

Gamma random numbers with unit scale

random*

Random numbers

random*

Simulate responses with random noise for linear regression model

random*

Simulate responses for generalized linear regression model

randsample*

Random sample

rangesearch*

Find all neighbors within specified distance using searcher object

rangesearch*

Find all neighbors within specified distance using input data

raylcdf

Rayleigh cumulative distribution function

raylinv

Rayleigh inverse cumulative distribution function

raylpdf

Rayleigh probability density function

raylrnd*

Rayleigh random numbers

raylstat

Rayleigh mean and variance

RegressionBaggedEnsemble*

Regression ensemble grown by resampling

RegressionEnsemble*

Ensemble regression

RegressionGP*

Gaussian process regression model class

RegressionLinear*

Linear regression model for high-dimensional data

RegressionSVM*

Support vector machine regression model

RegressionTree*

Regression tree

skewness*

Skewness

squareform*

Format distance matrix

std*

Standard deviation of probability distribution

table*

Table array with named variables that can contain different types

tcdf

Student's t cumulative distribution function

tinv

Student's t inverse cumulative distribution function

tpdf

Student's t probability density function

trnd*

Student's t random numbers

truncate*

Truncate probability distribution object

tstat

Student's t mean and variance

unidcdf

Discrete uniform cumulative distribution function

unidinv

Discrete uniform inverse cumulative distribution function

unidpdf

Discrete uniform probability density function

unidrnd

Random numbers from discrete uniform distribution

unidstat

Discrete uniform mean and variance

unifcdf

Continuous uniform cumulative distribution function

unifinv

Continuous uniform inverse cumulative distribution function

unifpdf

Continuous uniform probability density function

unifrnd*

Continuous uniform random numbers

unifstat

Continuous uniform mean and variance

update*

Update model parameters for code generation

var*

Variance of probability distribution

wblcdf

Weibull cumulative distribution function

wblfit

Weibull parameter estimates

wblinv

Weibull inverse cumulative distribution function

wblpdf

Weibull probability density function

wblrnd*

Weibull random numbers

wblstat

Weibull mean and variance

WeibullDistribution*

Weibull probability distribution object

zscore*

Standardized z-scores

See Also

| | |

Related Topics