External Interfaces Reference |
Get number of bytes required to store each data element
C Syntax
Arguments
array_ptr
Pointer to an mxArray
.
Returns
The number of bytes required to store one element of the specified mxArray
, if successful. Returns 0 on failure. The primary reason for failure is that array_ptr
points to an mxArray
having an unrecognized class. If array_ptr
points to a cell mxArray
or a structure mxArray
, then mxGetElementSize
returns the size of a pointer (not the size of all the elements in each cell or structure field).
Description
Call mxGetElementSize
to determine the number of bytes in each data element of the mxArray
. For example, if the mxClassID
of an mxArray
is mxINT16_CLASS
, then the mxArray
stores each data element as a 16-bit (2 byte) signed integer. Thus, mxGetElementSize
returns 2.
mxGetElementSize
is particularly helpful when using a non-MATLAB routine to manipulate data elements. For example, memcpy
requires (for its third argument) the size of the elements you intend to copy.
Examples
See doubleelement.c
and phonebook.c
in the refbook
subdirectory of the examples
directory.
See Also
mxGetDimensions | mxGetEps |
© 1994-2005 The MathWorks, Inc.