Incompatible type with mxCreateNumericArray
조회 수: 12 (최근 30일)
이전 댓글 표시
Hi, I'm trying to create a mexfunction but I have some problems with compilation... I wrote this piece of code:
//global variables int Y_dimx,Y_dimy,Y_dimz,nS; double *Y;
mexfunction() {
mxArray* dim = mxGetField(prhs[0],0,"dim");
double* Y_dim=(double*) mxGetData(dim);
Y_dimx = Y_dim[0];
Y_dimy = Y_dim[1];
Y_dimz = Y_dim[2];
nS = 72;
const int outDims[4] = {nS,Y_dimx,Y_dimy,Y_dimz};
plhs[0] = mxCreateNumericArray(4,outDims,mxDOUBLE_CLASS,mxREAL); (*)
Y = (double*)mxGetData(plhs[0]);
At line (*) I get the following compilation error: argument of type "const int *" is incompatible with parameter of type "const size_t * '
I can't understand the reason for this error... Can you help me? Thank you very much.. Davide
댓글 수: 0
채택된 답변
James Tursa
2014년 5월 24일
It is complaining because you declared outDims as an int array (which when used as an argument gets converted to const int *), but the function expected something else (const size_t *). Use an mwSize for this to be generic. Try this:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
:
const mwSize outDims[4] = {nS,Y_dimx,Y_dimy,Y_dimz};
댓글 수: 2
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!