MATLAB: How to find two arrays of a matrix are equal? and find their location in that matrix??? for example>>> suppose we have a=[1 3 5 6 3 7] how to find which arrays are equal with each other? and find their location??? thank you very much

histogram

example:
a=[1 3 5 6 3 7]; how to find that a(2)=a(5)????

Best Answer

a=[1 3 5 6 3 7]
[b,ii,jj]=unique(a)
[freq,idx]=histc(a,b)
location=arrayfun(@(x) find(a==x),b,'un',0)
out=[{'a' 'frequency' 'location'};[num2cell([b',freq']) location']]