I have a handle class in Matlab that I want to be able to use in C++. I already learned here that I can't just generate a C++ class, but have to wrap my class with functions. The example in the other question only shows the use of one member function in a wrapper function. However, I need to be able to call several member functions of my class.
As I cannot pass my class instance to the wrapper functions as per the Matlab documentation, I don't see a way of having several functions operate on the same object.
Is it not possible to do this?
Any help is appreciated.
You cannot have classes as input and output for the main function for which you generate code. But you can have any number of sub-functions called from your main function which can take the object as input. The object is typically created from your main function and passed to your sub-functions. You then generate code using codegen "main function name". The generated code contains all the sub-functions.
You also should use coder.inline('never') in your sub-functions so that they show up as separate functions in generated code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With