MATLAB: Hi, I want to compare the values (Mixture of text and number) in a row and have to find the repetitions? I have mentioned the problem in detail below: Please help!

columnshistcmatrixrepetitionrowstext and number mixedunique

StudentIDs_List=[100,101,102,103,104,104];
[n, bin] = histc(StudentIDs_List, unique(StudentIDs_List));
Multiple_IDs = find(n > 1);
Index = find(ismember(bin, Multiple_IDs));
StudentID_With_Repetition = StudentIDs_List(Index)
I will get result that finds the values with more occurrences like below
StudentID_With_Repetition =
104 104
What is the solution if StudentIDs_List is a mix of letters and numbers, i.e)
StudentIDs_List=[a100,a101,a102,a103,a104,a104];
The above code didn't help me for my problem? Any different approaches or solution? Thanks in Advance!

Best Answer

SL ={'a100','a101','a102','a103','a104','a104'};
[D,~,X] = unique(SL(:));
Y = hist(X,unique(X));
Index = find(Y > 1);
StudentID_With_Repetition = SL(Index)