Eine Matrix mit c ++ und mex ausgeben
Ich habe ein Problem mit meinem C ++ - Code. Ich möchte eine Matrix mit k-Dimensionen aus meinem cpp-Programm an Matlab zurückgeben.
Die Matrix, die ich übergeben möchte, wird in gespeichertall_data
und ist eine Matrix der Größe(npoints+1) x ndims
.
Ich habe mich darum gekümmert und mir Folgendes ausgedacht:
//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 ];
Aber es geht nicht, wieall_data
ist einvector<vector<double>>
Variable und Matlab sagt:
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
Kann mir jemand weiterhelfen? Danke vielmals!