Summing rows by index using accumarray
Can I sum rows or columns over several indices without using a for loop? I have an n by n matrix, M , that represents the co-occurrence of vocabulary terms where n is the length of the vocabulary. I also have a n by n logical mask, L , which represents the pairs of vocabulary where the pair has the form (singular, plural). For example, in pseudo-code, L('octopus', 'octopuses') = True I want to add the entries in M for any pair which contains a plural to entry for the pair that contains the corresponding singular. For example, in pseudo-code, M_sum('octopus', 'swim') = M('octopus', 'swim') + M(