Get matrix size from a pointer- MEX
이전 댓글 표시
Hello folks,
I read the second variable in C++
#define D prhs[1]
double** *d = mxGetPr(D); // get the pointer
Now I want to get the size of D
int mySize = mxGetM(D);
cool...Now how can I get the size from the pointer d (not D)?
int mySize = mxGetM((const mxArray) d); // does not work
Thanks,
답변 (1개)
Walter Roberson
2015년 8월 24일
You cannot do that. MATLAB can store multiple arrays as pointing to the same data, as long as all of the arrays have the same total number of elements. There is no one "size" for a data block.
P = rand(52,5);
Q = reshape(P, 13, 5, 4);
P and Q will have the same data pointer. R = reshape(Q, 13, 4, 5) would have the same data pointer too and probably makes more sense, but reshape() does not care about whether the reshape makes sense, only that the number of elements remains constant.
카테고리
도움말 센터 및 File Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!