Example MATLAB class wrapper for a C++ class

버전 (8.28 KB) 작성자: Oliver Woodford
An example of how to safely encapsulate a C++ class in a MATLAB class, via a mex interface.

다운로드 수: 7.9K

업데이트 날짜: 2018/2/8

라이선스 보기

편집자 메모: This file was selected as MATLAB Central Pick of the Week

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:
>> run_example
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 (2023). 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. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2012b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보

Added a standard interface to avoid needing an interface class per mex wrapper. Also added an example script.

Add #includes suggested by Richard Crozier (thanks) to fix compilation in Linux.

2nd attempt to fix compilation under linux.

Fix compile error in Linux - thanks to Andreas for highlighting the issue.