I want to work with 3D array in a mex function but my code doesn't compile (error C2109)
It is something like this:
#include "matrix.h"#include "mex.h"#define phi prhs[0]void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){ int nDimNum; const int *pDims; double *pD; mxArray *Data; nDimNum = mxGetNumberOfDimensions(phi); pDims = mxGetDimensions(phi); Data = mxCreateNumericArray(nDimNum, pDims, mxDOUBLE_CLASS, mxReal); pD = (double *) mxGetPr(Data); for(i=i; i<pDims[0]; i++) { for(j=0; j<pDims[1]; j++) { for(k=0; k<pDims[2]; k++) { pD[i][j][k]=i*100+j*10+k;} } } ... }
The compiling error C2109 says in the line with pD[i][j]… that the index requires an array or a pointer type.
Is there a way to work with a three-dimensional mxArray in that manner, that means, accessing single cells with this (or similar) notation?
Best Answer