MATLAB: Find the most common string out of all the strings

commoncompareMATLABstring

I have four strings like this: s1 = 'Romeo' s2 = 'Juliet' s3 = 'Rambo' s4 = 'Juliet' s5 = 'Romeo' s6 = 'Romeo'
I want to compare s1 through s6 and find the most commonly repeated string which is 'Romeo' in this case. Condition checking and for loops appear like an over kill for this problem. Is there a simple solution ?

Best Answer

Edit: bug fix
s1 = 'Romeo'
s2 = 'Juliet'
s3 = 'Rambo'
s4 = 'Juliet'
s5 = 'Romeo'
s6 = 'Romeo'
c = {s1 s2 s3 s4 s5 s6};
[s,~,j]=unique(c);
s{mode(j)}
ans =
'Romeo'