【发布时间】:2012-08-25 18:27:35
【问题描述】:
我的 C++ 代码有问题。我想从我的 cpp 程序返回一个 k 维矩阵到 Matlab。
我要传递的矩阵存储在all_data,是一个大小为(npoints+1) x ndims的矩阵。
我一直在寻找如何做到这一点,我想出了:
//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 ];
但它不起作用,因为all_data 是一个vector<vector<double>> 变量,而matlab 说:
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
有人可以帮帮我吗?非常感谢!
【问题讨论】: