function yes = matchPieces(A, B, l, w) %Check to see if the matrices A and B (which must be the same size) %are the same up to rotation and reflection. if A == B yes = 1; return end if A == B(:, w:-1:1) yes = 1; return end if A == B(l:-1:1, :) yes = 1; return end if A == B(l:-1:1, w:-1:1) yes = 1; return end if l == w C = B'; if A == C yes = 1; return end if A == C(:, w:-1:1) yes = 1; return end if A == C(l:-1:1, :) yes = 1; return end if A == C(l:-1:1, w:-1:1) yes = 1; return end end yes = 0; return