Setting the Output of a MEX Function as One of the Inputs After In Place Manipulation
Afficher commentaires plus anciens
I have simple MEX function.
It gets 2 arrays and output one array.
I want to manipulate the input arrays in place within the MEX function and then chain one of the arrays as the output.
Basically something like:
```
// Get Data Pointers
double * mI = (double *)mxGetData(prhs[0]);
double * mO = (double *)mxGetData(prhs[1]);
// Work on data
MyFun(mI, mO); // Manipulate mO and mI in place
// Set output
plhs[0] = mxCreateNumericMatrix(0, 0, mxDOUBLE_CLASS, mxREAL);
mxSetDoubles(plhs[0], mxGetDoubles(prhs[1]));
mxSetM(plhs[0], mxGetM(prhs[1]));
mxSetN(plhs[0], mxGetN(prhs[1]));
```
Yet my code keep crashing (Eve when I comment my own function `MyFun` so basically all the code does is set the output to prhs[1]).
Any idea why? Is this not allowed?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!