可以用下面的代码详细理解mwArray和一般数组之间的区别
mwArray a(3, 2, mxDOUBLE_CLASS); double *aData; aData = new double[6]; int iii; for( iii=0; iii<6; ++iii) { aData[iii] = iii+1; } // print output std::cout << "a = " << std::endl; std::cout << aData[0] << ",\t" << aData[1] << std::endl; std::cout << aData[2] << ",\t" << aData[3] << std::endl; std::cout << aData[4] << ",\t" << aData[5] << std::endl; a.SetData(aData, 6); std::cout << "a(1,1)="<<a(1,1)<<std::endl; std::cout << "a(1,2)="<<a(1,2)<<std::endl; std::cout << "a(2,1)="<<a(2,1)<<std::endl; std::cout << "a(2,2)="<<a(2,2)<<std::endl; std::cout << "a(3,1)="<<a(3,1)<<std::endl; std::cout << "a(3,2)="<<a(3,2)<<std::endl;
a =
1, 2
3, 4
5, 6
a(1,1)=1
a(1,2)=4
a(2,1)=2
a(2,2)=5
a(3,1)=3
a(3,2)=6
原文地址:http://blog.csdn.net/u013018721/article/details/40556943