Code Generation for Handle Class Destructors - MATLAB & Simulink (original) (raw)

You can generate code for MATLAB® code that uses delete methods (destructors) for handle classes. To perform clean-up operations, such as closing a previously opened file before an object is destroyed, use a delete method. The generated code calls the delete method at the end of an object's lifetime, even if execution is interrupted by a run-time error. When System objects are destroyed, delete calls the release method, which in turn calls the user-defined releaseImpl. For more information on when to define a delete method in a MATLAB code, see Handle Class Destructor.

Guidelines and Restrictions

When you write the MATLAB code, adhere to these guidelines and restrictions:

Behavioral Differences of Objects in Generated Code and in MATLAB

The behavior of objects in the generated code can be different from their behavior in MATLAB in these situations: