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
Show older comments
example:
a=[1 3 5 6 3 7]; how to find that a(2)=a(5)????
Accepted Answer
More Answers (1)
Image Analyst
on 18 Aug 2014
There might be very very many elements that occur more than once in the array. I suggest you call histc() to get a count of all values and see which counts are 2 or greater.
a = randi(9, 1, 100)-5 % Sample data
histEdges = unique(a)
counts = histc(a, histEdges)
% Find locations
for k = 1 : length(counts)
if counts(k) >= 2
locations = find(a == histEdges(k))
end
end
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!