Using this variable:
>> syms a b c
>> x = [a b c]
x =
[ a, b, c]
And this mex file (symdetails.c):
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
if( nrhs ) {
mexPrintf("ClassID = %d\n",mxGetClassID(prhs[0]));
mexPrintf("ClassName = %s\n",mxGetClassName(prhs[0]));
mexPrintf("NumberOfElements = %d\n",mxGetNumberOfElements(prhs[0]));
mexPrintf("ElementSize = %d\n",mxGetElementSize(prhs[0]));
}
}
I get this result on a 32-bit system:
>> symdetails(x)
ClassID = 74
ClassName = sym
NumberOfElements = 1
ElementSize = 4
Even though at the command line I get this:
>> numel(x)
ans =
3
>> size(x)
ans =
1 3
So it appears the sym information is held in some special format and the regular size etc functions do not apply (as you have already discovered). The size-of-one-element is probably just reporting back the size of some pointers (same guess as yours). You can convert to a string inside a mex routine via the mexCallMATLAB facility with the "char" function. But to get the individual elements, without manually parsing the string inside your mex function, will probably require multiple mexCallMATLAB calls with "subsref" or something like that (I have never done this myself). To recover the actual size of the sym array you will probably have to mexCallMATLAB with "numel" or the like.