How can I find the most frequent character in say a list of words (cell array of strings)?
1 次查看(过去 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!