MATLAB: I’ve a matrix of 6×4 and i want to count the rows how many times it occur in a matrix

count the number of times the row occurs

let say the matrix is
A=[ 12 45 67 89
34 56 78 65
12 45 67 89
53 55 21 90
12 45 67 89
53 55 21 90 ]
i want the output to be as:
12 45 67 89 ----- 3 % because it occurs 3 times
34 56 78 65 ------1
53 55 21 90 ------2
plz help me

Best Answer

A=[ 12 45 67 89
34 56 78 65
12 45 67 89
53 55 21 90
12 45 67 89
53 55 21 90 ]
[a,b,c]=unique(A,'rows','stable');
v=arrayfun(@(x) sum(c==x),1:size(a,1))';
out=[a v]