Given two matrices having the same dimensions:
m1 = {{1, a, 2}, {4, 5, 0}, {g, a, d}}
m2 = {{1, b, 2}, {7, 2, 0}, {a, a, a}}
Is there a built-in function that can return a count count for the number of instances where two entries in the same matrix position are equal? In the above example, for instance, we would have count = 4.
Note that, because I need to have a mix of numerical and string values in each matrix, I can't simply subtract the two matrices and look for non-zero positions. I'd also like to have 0 valued items in either matrix.
m1 - m2 // N // Count[#, 0., {2}] &– Kuba Oct 11 '14 at 07:32Count. Apply it like so:Count[m1 - m2, 0 | 0., {2}]– m_goldberg Oct 11 '14 at 07:59