Main Content

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.

Classes

coder.ClassTypeRepresent set of MATLAB classes

Topics

Code Generation Basics

Input Specification

Usage Notes and Limitations

Troubleshooting

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.

Resolve Error: Code Generator Failed to Produce C++ Destructor for MATLAB Class

Troubleshoot generation of standalone code for C++ destructor of a MATLAB class.

Work Around Language Limitation: Code Generation Does Not Support Object Arrays

Troubleshoot code generation failure for arrays of objects in your MATLAB code.