Get matrix size from a pointer- MEX
Afficher commentaires plus anciens
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,
Réponses (1)
Walter Roberson
le 24 Août 2015
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.
Catégories
En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!