How to return two variable length vectors from C++ function to MATLAB using clibgen package?

8 views (last 30 days)
I'm using the clibgen package to build a MATLAB interface to a C++ library. I'm in full control of the C++ library, so I can modify the signature of the functions as suited. I'm trying to interface a class that exposes a method that returns two vectors of data with variable length. The length is determined at runtime and it can change at each call of the function.
An example could be something like this:
class MyClass {
void getVectors(std::vector<double>& output1, std::vector<double>& output2)
{
output1 = ...;
output2 = ...;
}
}
How can I wrap this function using the clibgen package to provide a easy-to-use interface in MATLAB? I can modify the C++ interface as I like, but I still haven't found a simple way to do that.
Note that I've already tried the case with a single vector to be returned: in that case the signature of the C++ function is simply
std::vector<double> getVectors();
and the clibgen package handles that perfectly!

Answers (0)

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!