Hello, is there a way to create mxArray from double *?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello, is there a way to create mxArray from double *?
0 comentarios
Respuesta aceptada
José-Luis
el 15 de Nov. de 2012
Editada: José-Luis
el 15 de Nov. de 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;
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Call C++ from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!