可以用下面的代码详细理解mwArray和一般数组之间的区别
mwArray a(, , mxDOUBLE_CLASS);
double *aData;
aData = new double[];
int iii;
for( iii=; iii<; ++iii)
{
aData[iii] = iii+;
}
// print output
std::cout << "a = " << std::endl;
std::cout << aData[] << ",\t" << aData[] << std::endl;
std::cout << aData[] << ",\t" << aData[] << std::endl;
std::cout << aData[] << ",\t" << aData[] << std::endl; a.SetData(aData, );
std::cout << "a(1,1)="<<a(,)<<std::endl;
std::cout << "a(1,2)="<<a(,)<<std::endl;
std::cout << "a(2,1)="<<a(,)<<std::endl;
std::cout << "a(2,2)="<<a(,)<<std::endl;
std::cout << "a(3,1)="<<a(,)<<std::endl;
std::cout << "a(3,2)="<<a(,)<<std::endl;
运行结果如图:【一位数组到多维数组的组织方式是列优先的】
a =
,
,
,
a(,)=
a(,)=
a(,)=
a(,)=
a(,)=
a(,)=