Filter löschen
Filter löschen

counting the duplicates

1 Ansicht (letzte 30 Tage)
NUR KHAIRUNNISA rahimi
NUR KHAIRUNNISA rahimi am 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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Thomas
Thomas am 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..

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by