Code Generation

MATLAB®
Coder™ generates readable and portable C and C++ code from Statistics and Machine Learning Toolbox functions that support code generation. For example, you can classify
new observations on hardware devices that cannot run MATLAB by deploying a trained support vector machine (SVM) classification
model to the device using code generation.

You can generate C/C++ code for the Statistics and Machine Learning Toolbox functions in several ways.

Code generation for the object function (predict,
random, knnsearch, or
rangesearch) of a machine learning model — Use
saveCompactModel, loadCompactModel, and
codegen. Save a trained
model by using saveCompactModel. Define an
entry-point function that loads the saved model by using loadCompactModel and
calls the object function. Then use codegen to generate code
for the entry-point function.

Code generation for the predict and update functions of an SVM model or a muticlass
error-correcting output codes (ECOC) classification model using SVM
binary learners — Create a coder configurer by using learnerCoderConfigurer and then generate code by using
generateCode. You can update model parameters in the
generated C/C++ code without having to regenerate the code.

Other functions that support code generation — Use codegen. Define an
entry-point function that calls the function that supports code
generation. Then generate C/C++ code for the entry-point function by
using codegen.