From: Ehsan Salari on
Hello,

I am trying to read a 2D array ("aper") from a mat file in C++ (Visual Studio) and assign it to a 2D array ("aper1"). I am using the following code:

MATFile *pmat;
mxArray *pa1;
int ** aper1;
aper = new int*[nbixel];
for (int i = 0; i < nbixel; i++)
{
aper[i] = new int[3];
}
//////////
pmat = matOpen(filename.c_str(), "r");
pa1 = matGetVariable(pmat, "aper");
aper1 = (int**)mxGetData(pa1);
mxDestroyArray(pa1);
matClose(pmat);

I can read the variable "aper" but I cannot assign it to aper1. Could you please let me know how I can read a 2D array in C++? In particular, can I use mxGetData in case of a 2D array?

Thanks!