/* * $Id: spm_global.c 4921 2012-09-13 11:16:21Z guillaume $ * John Ashburner */ #include "mex.h" #include "spm_mapping.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mwSize i, j, k; int m, n, v, b; double s, s1, s2; double *dat = NULL; MAPTYPE *map = NULL; static double M[] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1}; if (nrhs < 1 || nrhs > 3 || nlhs > 1) { mexErrMsgTxt("Incorrect usage."); } if (nrhs < 2) { s = mxGetNaN(); } else { s = mxGetScalar(prhs[1]); } b = (nrhs < 3) ? 1 : mxGetScalar(prhs[2]); map = get_maps(prhs[0], &n); for(v=1; vs1) { s2 += dat[j]; m++; } } if (b) s2 /= m; mxGetPr(plhs[0])[v] = s2; } free_maps(map, n); mxFree(dat); }