I have a problem with my c++ code. I want to return a matrix of k-dimensions from my cpp program to Matlab.
The matrix I want to pass is stored in all_data
, and is a matrix of size (npoints+1) x ndims
.
I have been looking how to do that, and I have come up with:
//send back points
vector< vector <double> > indexes = mxGetPr(plhs[0]);
for (int i=0; i < (npoints1+1); i++)
for (int j=0; j < ndims1; j++)
indexes[ i ][ j ] = all_data[ i ][ j ];
But it does not work, as all_data
is a vector<vector<double>>
variable, and matlab says:
error: conversion from 'double*' to non-scalar type
'std::vector<std::vector<double, std::allocator<double> >,
std::allocator<std::vector<double,
std::allocator<double> > > >' requested
Can someone help me out? Thanks a lot!