Effacer les filtres
Effacer les filtres

counting the duplicates

1 vue (au cours des 30 derniers jours)
NUR KHAIRUNNISA rahimi
NUR KHAIRUNNISA rahimi le 22 Nov 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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (1)

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

Catégories

En savoir plus sur Data Types dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by