/* Roger Jang, 20091205 */ #include #include #include "mex.h" #define INPUT prhs[0] /* Input Arguments */ #define OUTPUT plhs[0] /* Output Arguments */ int doubleSortFunction(const void *a, const void *b) { return(*(double *)a - *(double *)b); } /* Median computation, which put nan at end and do quick sort on those non-nan numbers */ /* (Actually there are more efficient ways of finding the median instead of do sorting first.) */ double vecNanMedian(double *vec, int vecLen){ double *tempVec=(double *)calloc(vecLen, sizeof(double)); int i, validCount=0; double temp, output; memcpy(tempVec, vec, vecLen*sizeof(double)); for (i=0; i