yoshi yoshi - 7 months ago 53
C Question

C Matlab Mex gateway file, printing phrs

I want to print the values of phrs to terminal and check their data type. I thought I got the first part:

mexPrintf("Value: %d\n",prhs[0]);

But that's giving me junk. What am I missing? (Probably something obvious) Is there a way to check data types and print them out?


To check prhs date type, i think you can use mxGetClassName(prhs[0]). To print its value, you need to dereference it again, as I remember correctly. For example:

double* data = mxGetPr(prhs[0]);
mexPrintf("Value: %f\n",data[0]);

Note, mxGetPr, returns pointer to double, so left it in this example.