I have two matrices A
and B
of identical dimensions. What's the simplest (shortest) way to find the indices of differing elements?
1 Answer
I've failed to find a duplicate so:
SparseArray[A - B]["NonzeroPositions"]
Position[A - B, x_ /; x != 0., {2}]
I hope those are numeric matrices, if not then you have to watch out on the Condition
in the second solution.