How to count the number of different strings in a string list?

11 visualizaciones (últimos 30 días)
Dear All
I would need some help on this:
I have the following string list:
AAA
ABB
CDE
ABB
CCR
AAA
FDR
I would need to count the different strings in this list which is, in this example 5, and this would be my output.
The acual list may have undreds of strings.
Many thanks in advance!
Para

Respuesta aceptada

Mischa Kim
Mischa Kim el 18 de En. de 2021
Hi, use
str = {'AAA','ABB','CDE','ABB','CCR','AAA','FDR'};
numstr = numel(unique(str))
  3 comentarios
Richard Cornish
Richard Cornish el 15 de Abr. de 2021
This is useful. I want a frequency plot of each unique string - any ideas?
Steven Lord
Steven Lord el 15 de Abr. de 2021
str = {'AAA','ABB','CDE','ABB','CCR','AAA','FDR'};
histogram(categorical(str))

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by