/*================================================================= * mxisclass.c * * mxisclass takes no input arguments and returns no output * arguments. It creates an inline MATLAB object, and then gets and * prints the fields of this object. * * This is a MEX-file for MATLAB. * Copyright 1984-2011 The MathWorks, Inc. * All rights reserved. *=================================================================*/ #include "mex.h" void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { mxArray *output, *input; int number_of_fields, field_num; (void) plhs; (void) prhs; /* unused parameters */ /* Check for proper number of input and output arguments */ if (nrhs !=0) { mexErrMsgIdAndTxt( "MATLAB:mxisclass:maxrhs", "No input argument required."); } if(nlhs > 1){ mexErrMsgIdAndTxt( "MATLAB:mxisclass:maxlhs", "Too many output arguments."); } input=mxCreateString("sin(3*x)"); /* Use mexCallMATLAB to call the constructor and create the * object in MATLAB */ mexCallMATLAB(1,&output, 1, &input,"inline"); mxDestroyArray(input); /* Verify that the output an inline object, if it is get * its fields and print them. */ if (!mxIsClass(output, "inline")) { mxDestroyArray(output); mexErrMsgIdAndTxt( "MATLAB:mxisclass:ctorFailed", "Failed to create an object of class inline"); } number_of_fields = mxGetNumberOfFields(output); mexPrintf("This object contains the following fields:\n"); mexPrintf("name\t\tclass\t\tvalue\n"); mexPrintf("-------------------------------------\n"); /* Get the first field name, then the second, and so on. */ for (field_num=0; field_num