Afficher commentaires plus anciens
hi!how can i find the most frequent word in string in matlab?
Réponse acceptée
Plus de réponses (1)
Sean de Wolski
le 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 commentaire
reyhane
le 29 Mai 2012
Catégories
En savoir plus sur Language Support dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!