How can I find the most frequent character in say a list of words (cell array of strings)?
2 ビュー (過去 30 日間)
古いコメントを表示
How can I find the most frequent character in say a list of words (cell array of strings)?
For example a list like: hello, what, is, your, name,
0 件のコメント
採用された回答
Niko
2015 年 11 月 4 日
Are you looking for the most frequent character in each word? if so you can do
cellfun(@mode,{'hello','what','is','your','name'})
which gives you the string 'laioa'.
or if you want the most frequent character in all words,
mode(strjoin({'hello','what','is','your','name'},''))
gives you the character 'a'.
2 件のコメント
Niko
2015 年 11 月 4 日
You don't need the braces, so something like
cellfun(@mode,dictionary)
will work.
Niko
2015 年 11 月 5 日
if you have
dictionary={'hello','what','is','your','name'};
index=[0,1,1,0,1];
then
dictionary(logical(index))
will give you {'what','is','name'}.
I'm not sure if this is what you are asking...
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!