Incompatible type with mxCreateNumericArray
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
James Tursa
am 24 Mai 2014
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!