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.ClassType | Represent set of MATLAB classes acceptable for input specification |
Topics
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 Value Class Objects as Inputs
Specify that an entry-point input is an object of a value class. - Define Types of Entry-Point Inputs by Using the MATLAB Coder App
Specify the types of entry-point function inputs using the MATLAB Coder™ app.
Usage Notes and Limitations
- MATLAB Classes Definition for Code Generation
Use classes in MATLAB code intended for code generation. - Classes That Support Code Generation
Generate code for MATLAB value and handle classes and user-defined System objects. - 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.
Troubleshooting
Handle Object Limitations for Code Generation
Adhere to code generation restrictions for handle objects.
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.