So I am currently using \'accumarray\' to find the averages of a range of numbers wich correspond to matching ID\'s. Ex Input:
ID----Value
1 215
1 33
Instead of using accumarray
, you can directly compute a weighted mean, or many other functions, quite easily:
nIDs = length(unique(ID));
WeightedMean = zeros(nIDs, 1);
for ii = 1:nIDs
iID = (ID == ii);
WeightedMean(ii) = (Value(iID)' * Weight(iID)) / sum(Weight(iID));
end
Is there a specific reason you wish to do this through accumarray
?