MATLAB: Square matrix with relationships among equal rows.

findforfor loopindexingMATLAB

I have a matrix with the following form:
A = [ 9 9 9; 5 6 5; 9 9 9; 4 4 2; 5 6 5; 5 6 5; 4 4 4; 9 9 9]
If a particular row is equal to another, I am searching for a square matrix that contains ones, when a particular row is equal to another. Therefore if row 3 is equal to row 1, I want the elements B(1,3) and B(3,1) of a new matrix B, to be equal to 1.

Best Answer

B = ~squareform(pdist(A));