Word counting in a loop
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Xymbu
am 9 Feb. 2021
Beantwortet: Gaurav Garg
am 12 Feb. 2021
I have a while loop running where I bring in a sentence on every loop
Sentence(i) = ('some string of words');
I can split the words and count using the unique() function but...
I want to keep adding to a table that contains each unique word and the number of times it repeats
so it looks like...
while
Sentence(i) = ('some string of words that changes each iteration');
Words = splitlines(Sentence(i))
PL = (Words== "");
Words(PL) = [];
AnalysisWords = strings(0);
for i = 1:length(Words)
AnalysisWords = [AnalysisWords ; split(Words(i))];
end
AnalysisWords = lower(AnalysisWords);
[words,N,idx] = unique(AnalysisWords);
end
Im not sure how to turn this into a running list
1 Kommentar
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!