counting the duplicates

조회 수: 2 (최근 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 CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by