mexCallMATLAB ... Help me please.

Hi Everyone I am new in this. Let me ask you a dumb question about MEX routines.
I am trying to implement mexCallMATLAB(1, &B, 1, &A, "floor"); inside a routine, but I cannot figure out how to setup B and A as any number. I have tried everything but I have not had good results. This is the code. I need B as an input to other calculations at the end. But it seems that I am not getting anything from mexCallMATLAB.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
mxArray *A, *B;
double *d;
d = (double*)mxMalloc(1 * sizeof( double ));
A = mxCreateNumericMatrix(0, 0, mxDOUBLE_CLASS, mxREAL);
d[0] = 3.123;
mxSetData(A, d);
mexCallMATLAB(1, &B, 1, &A, "floor");
plhs[0] = B;
..... More code....}

Respuestas (1)

James Tursa
James Tursa el 8 de Jun. de 2012

1 voto

mxArray *A;
double *d;
A = mxCreateNumericMatrix(1, 1, mxDOUBLE_CLASS, mxREAL);
d = mxGetPr(A);
d[0] = 3.123;
mexCallMATLAB(1, plhs, 1, &A, "floor");

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 8 de Jun. de 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by