MATLAB Classes

Code generation for MATLAB® Classes

You can generate code for MATLAB classes, including value classes, handle classes, and System objects. In the generated C code, MATLAB classes are represented as structures. If you generate C++ code, the default behavior of the code generator is to produce C++ classes for the MATLAB classes. You must be aware of certain usage notes and limitations when using classes in your MATLAB code that is intended for code generation.


coder.ClassTypeRepresent set of MATLAB classes


Code Generation Basics

Generate Code for MATLAB Value Classes

Use a value class in MATLAB code intended for code generation.

Generate Code for MATLAB Handle Classes and System Objects

Use your System object™ in MATLAB code intended for code generation.

Generate C++ Classes for MATLAB Classes

Generate a C++ class for a value class, handle class, or System object in your MATLAB code.

Input Specification

Specify Objects as Inputs at the Command Line

Specify that an entry-point input is an object of a value class by using the codegen -args option.

Specify Objects as Inputs in the MATLAB Coder App

Define the type of a value class input from a test file or an example input.

Usage Notes and Limitations

MATLAB Classes Definition for Code Generation

Use classes in MATLAB code intended for code generation.

System Objects in MATLAB Code Generation

Special considerations for using System objects in code generated from MATLAB

Code Generation for Handle Class Destructors

Use a handle class destructor in MATLAB code intended for code generation.


Handle Object Limitations for Code Generation

Adhere to code generation restrictions for handle objects.

Class Does Not Have Property

Troubleshoot issues with assignment of a property of a handle class.

Passing By Reference Not Supported for Some Properties

You cannot use certain properties with coder.ref, coder.rref, or coder.wref.