MATLAB: Counting the duplicates

cell array

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

Best Answer

How about:
length(longwords)-length(unique(longwords))