samer@57: function H=accumhist(I,W,D) samer@57: % accumhist - Just like accumarray but filters out rows with nans or infs samer@57: % samer@57: % accumhist :: samer@57: % [[N,E]->(natural|nan|inf|-inf)] ~'N rows of E-dim array indices', samer@57: % ([[N]->real] | real) ~'the weights associated with each row', samer@57: % D:[[E]->natural] ~'the size of the array to return' samer@57: % -> [[D]]. samer@57: % samer@57: % Note that unlike with accumarray and other Matlab builtins, the size samer@57: % argument D can be a single element, eg [M], indicating that a vector samer@57: % is desired. accumarry would require [M 1]. samer@57: samer@57: H = accumarray(I(all(isfinite(I),2),:),W,tosize(D)); samer@57: