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

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,

 Respuesta aceptada

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 comentarios

You don't need the braces, so something like
cellfun(@mode,dictionary)
will work.
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...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Preguntada:

el 4 de Nov. de 2015

Comentada:

el 5 de Nov. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by