Search code examples
c++matlabmex

Convert std::vector<double> to matlab setVariable usable array


I have a std::vector of doubles and I need to pass this data to Matlab (to plot). How can I convert the vector into a Matlab readable vector?


Solution

  • You can use .data() to access the underlying block of memory. Combined with .size(), you can get access to a C-like array, which you then pass to MATLAB.