Old style obects (i.e., those using exclusively the @classname directory structure) were stored internally as structs, which made it easy to get at the data using mxGetField, mxGetFieldByNumber, etc. If you were using those objects they are easy to deal with in a mex routine.
New style classdef objects are stored in a completely different manner. The guts of the object are behind the Pr and Pi pointers, but exactly how this storage is arranged has never been publicized so you can't directly get at the data with official API functions. If it was a property you could use mxGetProperty (or the FEX submission mxGetPropertyPtr). But in the case of Enumeration there is no property for you to get. The only solution I can think of off the top of my head is to use mexCallMATLAB and convert it to something that you can deal with in a mex routine, e.g. a 32-bit integer. For example:
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
mxArray *mxi;
const int dims[2] = {1, 1};
plhs[0] = mxCreateNumericArray(2, dims, mxDOUBLE_CLASS, mxREAL);
double *temp = (double*)mxGetData(plhs[0]);
const mxArray *rhs = prhs[0];
mxArray *a = mxGetField(rhs, 0, "a");
mexCallMATLAB(1,&mxi,1,&a,"int32");
int32_T *value = (int32_T *)mxGetData(mxi);
double valueDouble = (double)(*value);
*temp = valueDouble;
}
>> temp.a = testEnum.Test1
temp =
a: [1x1 testEnum]
>> testEnum_mexs(temp)
ans =
1
Best Answer