MATLAB Application Program Interface Reference | Help Desk |
mxIsChar
True if a stringmxArray
#include "matrix.h" bool mxIsChar(const mxArray *array_ptr);array_ptr
true
if array_ptr
points to an array having the class mxCHAR_CLASS
; otherwise, returns false
.
Use mxIsChar
to determine if array_ptr
points to string mxArray
.
Calling mxIsChar
is equivalent to calling
mxGetClassID(array_ptr) == mxCHAR_CLASSConsider a MEX-file that expects its first input argument to be a string
mxArray
. If it is not a string mxArray
, the MEX-file issues an error message.
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { if (mxIsChar(prhs[0])) { /* ... Yes, it is a string mxArray. */ } else /* No, this is not a string array. */ mexErrMsgTxt("You must specify a string array"); }For an additional example, see
mxIsChar.c
in the mx
subdirectory of the examples
directory.
mxIsClass
, mxGetClassID