mexCallMATLAB ... Help me please.
Mostra commenti meno recenti
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....}
Risposte (1)
James Tursa
il 8 Giu 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");
Categorie
Scopri di più su Write C Functions Callable from MATLAB (MEX Files) in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!