/*================================================================= * The main routine analyzes all incoming (right-hand side) arguments * * Copyright 1984-2011 The MathWorks, Inc. * *=================================================================*/ #include #include #include "mex.h" void display_subscript(const mxArray *array_ptr, mwSize index); void get_characteristics(const mxArray *array_ptr); mxClassID analyze_class(const mxArray *array_ptr); /* Pass analyze_cell a pointer to a cell mxArray. Each element in a cell mxArray is called a "cell"; each cell holds zero or one mxArray. analyze_cell accesses each cell and displays information about it. */ static void analyze_cell(const mxArray *cell_array_ptr) { mwSize total_num_of_cells; mwIndex index; const mxArray *cell_element_ptr; total_num_of_cells = mxGetNumberOfElements(cell_array_ptr); mexPrintf("total num of cells = %d\n", total_num_of_cells); mexPrintf("\n"); /* Each cell mxArray contains m-by-n cells; Each of these cells is an mxArray. */ for (index=0; index 16) { sprintf(shape_string, "%"FMT_SIZE_T"u-D", number_of_dimensions); } mexPrintf("Dimensions: %s\n", shape_string); /* Display the mxArray's class (category). */ class_name = mxGetClassName(array_ptr); mexPrintf("Class Name: %s%s\n", class_name, mxIsSparse(array_ptr) ? " (sparse)" : ""); /* Display a bottom banner. */ mexPrintf("------------------------------------------------\n"); /* free up memory for shape_string */ mxFree(shape_string); } /* Determine the category (class) of the input array_ptr, and then branch to the appropriate analysis routine. */ mxClassID analyze_class(const mxArray *array_ptr) { mxClassID category; category = mxGetClassID(array_ptr); if (mxIsSparse(array_ptr)) { analyze_sparse(array_ptr); } else { switch (category) { case mxLOGICAL_CLASS: analyze_logical(array_ptr); break; case mxCHAR_CLASS: analyze_string(array_ptr); break; case mxSTRUCT_CLASS: analyze_structure(array_ptr); break; case mxCELL_CLASS: analyze_cell(array_ptr); break; case mxUNKNOWN_CLASS: mexWarnMsgIdAndTxt("MATLAB:explore:unknownClass", "Unknown class."); break; default: analyze_full(array_ptr); break; } } return(category); } /* mexFunction is the gateway routine for the MEX-file. */ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { int i; (void) nlhs; /* unused parameters */ (void) plhs; /* Check to see if we are on a platform that does not support the compatibility layer. */ #if defined(_LP64) || defined (_WIN64) #ifdef MX_COMPAT_32 for (i=0; i