Try this:
A = randi(1000, 60, 5);
[Au,~,ix] = unique(A,'stable');
tally = accumarray(ix,1);
keep = tally > 1;
out1 = [Au(keep), tally(keep)];
Ai = ismember(A,out1(:,1));
Anew = A .* Ai;
The ‘Anew’ matrix has 0 values for the elements that are not repeated, those that are repeated appear in their expected locations.
If you only want the values of the numbers that aare repeated, and the number of repeats, those are contained in the ‘out1’ matrix.
Best Answer