Legacy code, c++ class
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I have c++ class. I want to use this c++ class in matlab/simulink. How I can do this ? i read something about legacy code but i didnt understand. Please help me. Thanks a lot.
Best regards
0 件のコメント
回答 (1 件)
Archita P
2017 年 5 月 31 日
Enter the following command in the MATLAB command window-
>> sfundemos
It has examples for C++ integration.
You can refer to the following link for more information- https://www.mathworks.com/help/simulink/sfg/s-function-examples.html
You can also use a MEX file to construct a new instance of the C++ object and return a pointer to it in MATLAB by encoding the pointer in an int64 matrix for example. Then you can pass this matrix back to the same or a different MEX file that will decode it and use it. You could use a MATLAB class to encapsulate the MEX files that use the C++ class and the encoding of the C++ pointer. A handle class destructor could be used to call a MEX file that deletes the C++ object.
An example of this approach can be found in the following file exchange link-
You can also use the legacy code tool to integrate C functions with MATLAB. Refer to the link mentioned below for more information-
https://www.mathworks.com/help/simulink/sfg/integrating-existing-c-functions-into-simulink-models-with-the-legacy-code-tool.html
But, the Legacy Code Tool can interface with C++ functions, but not C++ objects.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!