Ältere Kommentare anzeigen
hi!how can i find the most frequent word in string in matlab?
Akzeptierte Antwort
Weitere Antworten (1)
Sean de Wolski
am 29 Mai 2012
Something like:
str = 'See Spot run, see Spot jump, see Spot eat';
C = regexp(lower(str),' ','split')';
[val,idxC, idxV] = unique(C);
n = accumarray(idxV,1);
[n idxC] %n occurences for word C(idxC)
obviously this needs to be augmented to take into account punctuation, whether you want to account for caps etc.
1 Kommentar
reyhane
am 29 Mai 2012
Kategorien
Mehr zu Language Support finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!