Comparing matrix elements

the operation A == B produces a logical array of the same dimensions as A and B, with Is in locations where the corresponding elements of A and B match, and Os elsewhere.

Consider the following illustration

>> A = [1 2 3; 9 6 3; 3 1 6]

A =

     1     2     3
     9     6     3
     3     1     6

>> B = [1 3 6; 6 6 3; 3 6 9]

B =

     1     3     6
     6     6     3
     3     6     9

>> A==B

ans =

     1     0     0
     0     1     1
     1     0     0