Hello, is there a way to create mxArray from double *?

5 Ansichten (letzte 30 Tage)
Alexmyak
Alexmyak am 15 Nov. 2012
Hello, is there a way to create mxArray from double *?

Akzeptierte Antwort

José-Luis
José-Luis am 15 Nov. 2012
Bearbeitet: José-Luis am 15 Nov. 2012
If by create you mean typecasting, then no. If by create you mean populate then yes:
mwSize m = 100, n = 10; //Array size
double * yourData = new double[m*n]; //Need to populate with the data you want
mxArray *pa = mxCreateDoubleMatrix(m, n , mxREAL)
double *startPa = mxGetPr(pa);
//In C
memcpy ( startPa, yourData, m*n*sizeof(double) );
//Alternatively
copy ( pa, pa+(m*n), yourData );
delete yourData;

Weitere Antworten (0)

Kategorien

Mehr zu Call C++ from MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by