我正在使用 MATLAB/C++ API。
我正在尝试从 2D C++ 数组创建 2D MATLAB 数组。这是我尝试过的:
double testCppArr[243][5];
// Fill the testCppArr with data
mwArray *testMatlabArr = new mwArray(243, 5, mxDOUBLE_CLASS);
testMatlabArr->SetData(testCppArr[0], 243 * 5);
这是为我创建的长度为 243×5 的 vector ,而不是具有 243 行和 5 列的矩阵。我知道这在内存中是一样的,但我想创建一个矩阵而不是 vector 。
错在哪里?
我也读过 the MATLAB documentation , 但没有找到解决方案
最佳答案
问题中的代码定义了一个 2D MATLAB 矩阵。 我的问题出在读取的矩阵数据中。
关于c++ - 使用 C++ MATLAB API 定义二维数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37021706/