Unable to retrive C array in Matlab
Mostra commenti meno recenti
Hi Friends
I am working on a C++ Project with various functions performed by Matlab C++ shared library. I need to pass an array to the Matlab code. Here's an example of how I', doing it :
if true
double mat[] = {
11, 21,
12, 22,
13, 23,
14, 24
};
uchar *mat2 ;
//mat2 = (uchar*) malloc(sizeof(uchar));
mat2 = (uchar*) &mat[0];
// Allocate memory. mxCOMPLEX for complex array
mxArray* X = mxCreateDoubleMatrix(nRow, nCol, mxREAL);
// Assign
memcpy(mxGetPr(X), mat2, nRow*nCol*sizeof(double));
// When using the mex -largeArrayDims switch, mwSize is equivalent to size_t
double *xValues = mxGetPr(X);
// for(int i =0;i<8;i++) Trial 1
// {
// qDebug()<<xValues[i];}
mwArray X1(X);
justcheck(X1);
end
The Problem is that when I open up the trial 1 comment, I do get the data as such. But when I send it to the function "justcheck(), I get that X1 has only one element which is equal to 1.
Can you please help me find out my error?
Thank you
Regards Alok
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Deploy to C++ Applications Using mwArray API (C++03) in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!