Hello,
you can refer my answer as follows
clear
A= [4 4; 2 3; 4 2; 3 3; 2 3; 1 3; 3 3];
B=[1 1; 2 1; 3 1; 4 1; 1 2; 2 2; 3 2; 4 2; 1 3; 2 3; 3 3; 4 3; 1 4; 2 4; 3 4; 4 4];
n = size(A,1);
rowAinB = [];
for i = 1:n
[LIA,LOCB] = ismember(A(i,:),B,'rows','legacy');
if ~isempty(LOCB)
rowAinB = [rowAinB i];
end
end
repeatA = [];
C = unique(A,'rows','stable');
for i = 1:n
[LIA,LOCB] = ismember(A(i,:),C,'rows','legacy');
repeatA = [repeatA LOCB];
end
m = size(C,1);
coutrepeatA = zeros(m,1);
for i = 1:m
idx = find(repeatA == repeatA(i));
coutrepeatA(i) = length(idx)-1;
end
the unique of matrix A is C and number of repeated row of C is stored in vector "coutrepeatA". As you can see the results below
A =
4 4
2 3
4 2
3 3
2 3
1 3
3 3
C =
4 4
2 3
4 2
3 3
1 3
coutrepeatA =
0
1
0
1
1
Best regards,
Trung
Best Answer