Effacer les filtres
Effacer les filtres

Returning a vector from C++ to matalb through mex?

3 vues (au cours des 30 derniers jours)
Eric Nunes
Eric Nunes le 4 Nov 2013
HI, I am trying to return a vector back to matlab using the mex function. I declare a return pointer as, double *retPtr = NULL;
Then the return code is as follows: plhs[0] = mxCreateDoubleMatrix(N, 1, mxREAL); retPtr = mxGetPr(plhs[0]);
for (int i = 0; i < N; i++) { retPtr[i] = forest->predictLabel(&(testData[i*M]), M); }
The return type is a vector<int> , but I keep on getting the error: Error 1 error C2440: '=' : cannot convert from 'std::vector<_Ty>' to 'double'
I there a problem the way I declare the pointer. Any help would be appreciated.
Regards, Eric

Réponses (0)

Catégories

En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by