필터 지우기
필터 지우기

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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by