mexCallMATLAB ... Help me please.
Afficher commentaires plus anciens
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....}
Réponses (1)
James Tursa
le 8 Juin 2012
mxArray *A;
double *d;
A = mxCreateNumericMatrix(1, 1, mxDOUBLE_CLASS, mxREAL);
d = mxGetPr(A);
d[0] = 3.123;
mexCallMATLAB(1, plhs, 1, &A, "floor");
Catégories
En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!