フィルターのクリア

counting the duplicates

1 回表示 (過去 30 日間)
NUR KHAIRUNNISA rahimi
NUR KHAIRUNNISA rahimi 2011 年 11 月 22 日
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

採用された回答

Daniel Shub
Daniel Shub 2011 年 11 月 22 日
How about:
length(longwords)-length(unique(longwords))
  1 件のコメント
NUR KHAIRUNNISA rahimi
NUR KHAIRUNNISA rahimi 2011 年 11 月 22 日
yup, i used exactly this one!thank you!

サインインしてコメントする。

その他の回答 (1 件)

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

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by