spm_hist.m 649 B

12345678910111213141516171819
  1. function h = spm_hist(ind,val)
  2. % Generate a weighted histogram - a compiled routine
  3. % FORMAT h = spm_hist(ind,val)
  4. % ind - indices (unsigned byte)
  5. % val - weights
  6. %__________________________________________________________________________
  7. % Copyright (C) 1999-2014 Wellcome Trust Centre for Neuroimaging
  8. % John Ashburner
  9. % $Id: spm_hist.m 6157 2014-09-05 18:17:54Z guillaume $
  10. %-This is merely the help file for the compiled routine
  11. %error('spm_hist.c not compiled - see Makefile')
  12. h = accumarray(double(ind(:))+1,double(val(:)),[256 1]);
  13. %-Alternative code for older MATLAB versions
  14. %h = full(sparse(double(ind)+1,ones(size(ind)),val,256,1));