MATLAB: Quick method to find duplicates in a matrix duplicatesloops Hi guys, Does anybody know a quick way of checking to see which elements of a matrix are duplicates? Such as: a = [1,2,3,4,5,5,1,6,7]; Can we have matlab return the indices of all 1's and 5's or return: 1, 5 Thanks! Best Answer You can try: [uniqueA i j] = unique(A,'first'); indexToDupes = find(not(ismember(1:numel(A),i)))There may be some parameters in the unique() function to get exactly what you desire but i don't remember it off hand. Related SolutionsMATLAB: How to give ranking from highest to lowest This should give you the rank you are asking for, Mekala: [~,p] = sort(Data,'descend'); r = 1:length(Data); r(p) = r;'r' will be the ranking. MATLAB: Finding duplicates Here is one way:[uniqueA i j] = unique(A,'first');indexToDupes = find(not(ismember(1:numel(A),i))) Related QuestionFinding only unique valuesHow can i find an eleiment which comes only one in a matrix ????Finding the Frequency of Unique ValuesReplace the unique value of a vectorHow to count repeated character in string ?
Best Answer