Incompatible type with mxCreateNumericArray

11 Ansichten (letzte 30 Tage)
davide
davide am 24 Mai 2014
Kommentiert: lau am 11 Jan. 2018
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

Akzeptierte Antwort

James Tursa
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
davide
davide am 28 Mai 2014
Thamk you so much
lau
lau am 11 Jan. 2018
Very useful answer, thank you very much@

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

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!

Translated by