How can I generate C++ code for a user defined MATLAB class

조회 수: 14 (최근 30일)
Antonio Aguirre
Antonio Aguirre 2016년 12월 20일
답변: Walter Roberson 2016년 12월 21일
I need to export a user-defined MATLAB class to C++. I need the class to have multiple instances in the C++ environment.
I understand that you can wrap the class with a function, however, I do not want to do this because of the intended dynamic use of the class methods. More specifically, I feel there would be unnecessary short circuiting of the wrapper function handling of the class object via inputs to the function.
Alternatively, I have explored creating a simple SIMULINK model to export the class directly, which works. However, I am curious to any alternatives that have worked for others.
I am merely looking for suggested methods for exporting my classdef to C++, thank you.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 12월 21일
My understanding is that code will only be generated for signatures which are invoked by some function you call (in a function outside of the class definition.) I do not think just exporting the class definition itself is possible, not without having called it with all the various signatures.

카테고리

Help CenterFile Exchange에서 Use Prebuilt MATLAB Interface to C++ Library에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by