This package provides an example of how to wrap a C++ class in a MATLAB class, via a mex interface, safely, without memory leaks, whilst achieving an interface in MATLAB that is similar to the underlying C++ interface.
After downloading, call:
in MATLAB to see an example implementation in action.
Look in run_example.m, example_mex.cpp (and optionally example_interface.m if you don't want to use the standard interface) to see how this is implemented, and copy the structure to interface with your own C++ classes.
This submission is inspired by the following newsgroup thread:
Thanks to all those who have contributed.
Oliver Woodford (2022). Example MATLAB class wrapper for a C++ class (https://www.mathworks.com/matlabcentral/fileexchange/38964-example-matlab-class-wrapper-for-a-c-class), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Inspired: C++ MEX Development Utilities, Kinect 2 Interface for Matlab, FELICITY, MATLAB class wrapper for a C++ implementation of a Quadtree, Message Passing Algorithm for Decoding Binary LDPC Codes, crobarcro/mcode-cpp-utilities, Ray casting for deformable triangular 3D meshes
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!