Incompatible type with mxCreateNumericArray
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
James Tursa
il 24 Mag 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Write C Functions Callable from MATLAB (MEX Files) in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!