| MATLAB Application Program Interface Reference | Help Desk |
mxIsEmpty
True ifmxArray is empty
#include "matrix.h" bool mxIsEmpty(const mxArray *array_ptr);array_ptr
true if the mxArray is empty; otherwise, returns false.
Use mxIsEmpty to determine if an mxArray is empty. An mxArray is empty if the size of any of its dimensions is 0.
Attempts to access empty mxArray cause undesirable behavior. To avoid accessing empty arrays, test them by calling mxIsEmpty.
Note that mxIsEmpty is not the opposite of mxIsFull.
mxGetScalar returns an indeterminate value if passed an empty mxArray. mxIsEmpty first:
void
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray
*prhs[])
{
double value;
/* If array is empty, it would not be good to access it. */
if (mxIsEmpty(prhs[0]))
mexErrMsgTxt("You cannot pass an empty array.\n");
else {
value = mxGetScalar(prhs[0]);
mexPrintf("First real value is %g\n", value);
}
}
For an additional example, see mxIsEmpty.c in the mx subdirectory of the examples directory.
mxIsClass