How do I get the program to display the most and least Freq used words? Tells me the # times used but I dont know how to get it to display the words. PLease Help!
古いコメントを表示
a =fileread('GreatExpectations.txt');
w = regexpi(a, ' ', 'split');
v = unique(w);
n = length(v);
counts = zeros(n,1);
for i=1:n
counts(i) = sum(strcmp(w, v{i}));
end
most_frequent =max(counts)
for i=1:n
counts(i) = sum(strcmp(w, v{i}));
end
least_frequent= min(counts)
採用された回答
その他の回答 (1 件)
Ahmet Cecen
2015 年 4 月 25 日
add to the end:
v{counts==most_frequent}
v{counts==least_frequent}
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!