MATLAB: Same Rows between two matrix

indexindexingmatrix

How do I find matricies with the same rows? I need to find unque Matricies.
A = [1 2; 3 4; 6 7], B = [3 4; 1 2; 6 7], C = [7 8; 8 2; 1 3], D = [1 2; 1 2; 6 7]
  • A is considered the same as B, since A(1,:) = B(2,:), A(2,:) = B(1,:) and A(3,:) = B(3,:).
  • A and B is not the same as C, since the rows do not match.
  • A, B is not considered the same as D, even when D(1,:) = A(1,:) but also D(2,:) = A(1,:).
  • Each rows (in matrix X) should correspond to the other row (in matrix Y).
  • all matrix have the same size.
Using the above rules, I only need unique matrix, so output should be just A, C and D. (I dont need index, but ok with it outputing index)

Best Answer

isequal(sortrows(A),sortrows(B));