unique characters in a cell

8 visualizaciones (últimos 30 días)
Max
Max el 8 de Nov. de 2015
Respondida: Geoff Hayes el 8 de Nov. de 2015
If I have a cell
x=
'sat'
'satire'
'sa'
'do'
How would I list all the unique letters that appear from the list so say uniqueletters='satiredo'

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 8 de Nov. de 2015
Max - is the order in your output important? If you use first convert your cell array of strings to a single string using strjoin and then use unique to determine the unique characters, you would get
unique(strrep(strjoin(x'),' ',''))
ans =
adeiorst
Note that we use strrep to replace/remove all the space characters in the joined string.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by