This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

mxGetNumberOfElements (C and Fortran)

Number of elements in array

C Syntax

#include "matrix.h"
size_t mxGetNumberOfElements(const mxArray *pm);

Fortran Syntax

mwPointer mxGetNumberOfElements(pm)
mwPointer pm



Pointer to an mxArray


Number of elements in the specified mxArray


mxGetNumberOfElements tells you how many elements an array has. For example, if the dimensions of an array are 3-by-5-by-10, mxGetNumberOfElements returns the number 150.

    Note:   Fortran does not have an equivalent of size_t. mwPointer is a preprocessor macro that provides the appropriate Fortran type. The value returned by this function, however, is not a pointer.


See the following examples in matlabroot/extern/examples/refbook.

See the following examples in matlabroot/extern/examples/mx.

See the following examples in matlabroot/extern/examples/mex.

Introduced before R2006a

Was this topic helpful?