q2 find elements in a matrix