How to convert a matlab::mex::ArgumentList to a custom C++-Type and vice versa
Show older comments
I have some C++ source code that is accessable in Simulink with the help of the Legacy Code Tool. I want the same C++ code also be callable from Matlab. My research led me to the "C++ MEX API" with which I am struggeling. If there is another simpler approach, please let me know.
My problem is that I need to wrap the arguments of the operator method
void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs)
into some user-defined C++ structs such that I can call my custom code
void myCode(userStruct1 &in, userStruct2 &out)
For simple inputs of operator() I managed to loop through "inputs" and the containing matlab::data::Array. I then assigned these values into my userStruct1 object. I find this procedure tedious but I can live with that. If there's an easier way to convert from matlab::data::ArgumentList to userStruct1 please let me know.
My problem, however, is the other way around. Assume myCode is called and the results are written in the userStruct2 object. How do I pass these results to "outputs"?
1 Comment
Accepted Answer
More Answers (1)
Friedrich
on 24 Oct 2024
Categories
Find more on MATLAB Data API for C++ in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!