mexCallMATLAB ... Help me please.
1 view (last 30 days)
Show older comments
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....}
0 Comments
Answers (1)
James Tursa
on 8 Jun 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");
0 Comments
See Also
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!