How can I find the most frequent character in say a list of words (cell array of strings)?

4 ビュー (過去 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,

採用された回答

Niko
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
Niko 2015 年 11 月 4 日
You don't need the braces, so something like
cellfun(@mode,dictionary)
will work.
Niko
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 ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by