| MATLAB Application Program Interface | Search  Help Desk |
| mxGetClassID | Examples See Also |
Get (as an enumerated constant) an mxArray's class
#include "matrix.h" mxClassID mxGetClassID(const mxArray *array_ptr);array_ptr
mxArray.
The class (category) of the mxArray that array_ptr points to. Classes are:
mxCELL_CLASS
mxArray.
mxSTRUCT_CLASS
mxArray.
mxOBJECT_CLASS
mxArray.
mxCHAR_CLASS
mxArray; that is an mxArray whose data is represented as mxCHAR's.
mxSPARSE_CLASS
mxArray; that is, an mxArray that only stores its nonzero elements.
mxDOUBLE_CLASS
mxArray whose data is stored as double-precision, floating-point numbers.
mxSINGLE_CLASS
mxArray whose data is stored as single-precision, floating-point numbers.
mxINT8_CLASSIdentifies a numeric
mxArray whose data is stored as signed 8-bit integers.
mxUINT8_CLASSIdentifies a numeric
mxArray whose data is stored as unsigned 8-bit integers.
mxINT16_CLASSIdentifies a numeric
mxArray whose data is stored as signed 16-bit integers.
mxUINT16_CLASSIdentifies a numeric
mxArray whose data is stored as unsigned 16-bit integers.
mxINT32_CLASSIdentifies a numeric
mxArray whose data is stored as signed 32-bit integers.
mxUINT32_CLASSIdentifies a numeric
mxArray whose data is stored as unsigned 32-bit integers.
mxINT64_CLASSReserved for possible future use.
mxUINT64_CLASSReserved for possible future use.
mxUNKNOWN_CLASS = -1The class cannot be determined. You cannot specify this category for an
mxArray; however, mxGetClassID can return this value if it cannot identify the class.
Use mxGetClassId to determine the class of an mxArray. The class of an mxArray identifies the kind of data the mxArray is holding. For example, if array_ptr points to a sparse mxArray, then mxGetClassID returns mxSPARSE_CLASS.
mxGetClassID is similar to mxGetClassName, except that the former returns the class as an enumerated value and the latter returns the class as a string.
Consider a MEX-file that can accept any kind of mxArray as its first input argument. If you intend to take action on the first input argument depending on its class, the first step is to call mxGetClassID.
void
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray
*prhs[])
{
mxClassID category;
category = mxGetClassID(prhs[0]);
switch(category) {
case mxCHAR_CLASS: analyze_string(prhs[0]); break;
case mxSTRUCT_CLASS: analyze_structure(prhs[0]); break;
case mxSPARSE_CLASS: analyze_sparse(prhs[0]); break;
case mxCELL_CLASS: analyze_cell(prhs[0]); break;
case mxUNKNOWN_CLASS: mexWarnMsgTxt("Unknown class."); break;
default: analyze_numeric(prhs[0]); break;
}
mxGetClassName