Borrar filtros
Borrar filtros

counting the duplicates

1 visualización (últimos 30 días)
NUR KHAIRUNNISA rahimi
NUR KHAIRUNNISA rahimi el 22 de Nov. de 2011
When I set
longwords={'banana';'milk';'butter';'cake';'lamb';'milk'}
no_duplicates=0;
for idup=1:length(longwords)
if ............ % so here in the cell i would like compare any string that are duplicates of each other and count them but im not sure how, can anybody tell me?Thank you.
no_duplicates=no_duplicates+1; end

Respuesta aceptada

Daniel Shub
Daniel Shub el 22 de Nov. de 2011
How about:
length(longwords)-length(unique(longwords))
  1 comentario
NUR KHAIRUNNISA rahimi
NUR KHAIRUNNISA rahimi el 22 de Nov. de 2011
yup, i used exactly this one!thank you!

Iniciar sesión para comentar.

Más respuestas (1)

Thomas
Thomas el 22 de Nov. de 2011
longwords={'banana';'milk';'butter';'cake';'lamb';'milk'}
uniqueWords=numel(unique(longwords))
unique(longwords)
repeatedWords=numel(longwords)-numel(unique(longwords))
Hope this helps..

Categorías

Más información sobre Data Types 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