MATLAB: How to get the most repeated element of a cell array

cell arrayelementsMATLABmatlab array

i have an cell array like this
{[];[];[];[];[];[];[];[];'rj';'rj';'rj';'rj';'rj';'rj';'rj';'rj';'rj';'rj';'rj';'rj';'rj';'rj';}
is there a way to get the label of this array as rj?

Best Answer

the cyclist >> I knew I had overlooked something easier. :-)
Well, look at how I did overlook something easier ;-D :
C = {[];[];[];[];[];[];[];[];'rj';'rj';'rj';'ab';'ab'} ;
setMatch = @(s,c) struct('string', s, 'count', c) ;
match = setMatch('', 0) ;
hashtable = java.util.Hashtable() ;
for k = 1 : length(C)
if isempty(C{k}), continue ; end
if hashtable.containsKey(C{k})
count = hashtable.get(C{k}) ;
if count >= match.count, match = setMatch(C{k}, count+1) ; end
hashtable.put(C{k}, count+1) ;
else
if match.count == 0, match = setMatch(C{k}, 1) ; end
hashtable.put(C{k}, 1) ;
end
end
Running this leads to;
>> match
match =
string: 'rj'
count: 3