Documentation

Code Generation

Generate C code and MEX functions for toolbox functions.

MATLAB®Coder™generates standalone, ANSI-compliant C code or MEX functions 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, binary or multiclass support vector machine classification model to the device using code generation.

Functions

saveCompactModel Save model object in file for code generation
loadCompactModel Reconstruct model object from saved model for code generation

Topics

Code Generation Support, Usage Notes, and Limitations

View a list of code-generation-enabled statistics functions, and corresponding limitations and other notes.

Code Generation Workflows

Generate code for Statistics and Machine Learning Toolbox functions including label prediction using classification models.

Code Generation Workflow for Exhaustive Searcher

使用生成代码寻找最近的邻居an exhaustive searcher model.

C Code Generation and Classification Learner

Generate code from a label prediction function that loads a classification model from Classification Learner.

Specify Variable-Sized Arguments for Code Generation

Generate code from a label prediction function that is flexible with respect to the number of observations and the dimensions of other parameter values.

C Code Generation for Image Classifier

This example shows how to generate C code from a MATLAB function that classifies images of digits using a trained classification model.

Predict Class Labels Using MATLAB Function Block

Generate code from a Simulink®model that classifies data using an SVM model.

System Objects for Classification and Code Generation

Generate code from a System object™ for making predictions using a trained classification model, and use the System object in a Simulink model.

Predict Class Labels Using Stateflow

Generate code from a Stateflow®model that classifies data using a discriminant analysis classifier.

Was this topic helpful?