Hello, is there a way to create mxArray from double *?
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello, is there a way to create mxArray from double *?
댓글 수: 0
채택된 답변
José-Luis
2012년 11월 15일
편집: José-Luis
2012년 11월 15일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!