How to call object methods with c++ engine api?
3 views (last 30 days)
I'm using C++ Engine Api to call MATLAB code from C++. I want to create an instance of a MATLAB class from C++ and call its methods. How can I achieve this?
Currently, I'm using this kind of approach to create the instance (Processor is the name of class I'm trying to use):
matlab = matlab::engine::startMATLAB();
matlab->eval(u"processor = Processor");
After that, I'm not sure what to do. I tried using
but I only get error Unrecognized function or variable 'processor.add_simple'.
There seems also to be matlab->getProperty and matlab->setProperty methods, but I want to get methods instead of properties.
Furthermore, the whole approach of using eval to create the instance seems pretty cumbersome. Is there a way to instantiate the class directly from c++, perhaps something like this:
auto instance = matlab->create_instance("class_name")
matlab->call_instance_method(instance, "method_name", args)
What is the correct way of using C++ Engine Api with class instances?