Mostra commenti meno recenti
hi!how can i find the most frequent word in string in matlab?
Risposta accettata
Più risposte (1)
Sean de Wolski
il 29 Mag 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 Commento
reyhane
il 29 Mag 2012
Categorie
Scopri di più su Language Support in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!