Reputation: 855
I want to find the highest peak points in the below histogram. For example as it is seen in the figure, I should select 4 peak points, but I get this 4 points information after seeing the histogram, so I need to find it by coding. Is there any method or algorithm to solve this problem?
If I select manually I could solve the problem. However, I do not know the number of the highest peak points. Actually the main problem is determining a threshold.
[pks,locs] = findpeaks(difference)
[sortedX,sortingIndices] = sort(difference,'descend');
locsize=size(locs,2);
counter=1;
peak_order=[];
while counter<5
for j=1:locsize
if sortingIndices(counter)==locs(j)
peak_order(counter)=sortingIndices(counter);
counter=counter+1;
end
end
end
sorted_peak_order=sort(peak_order)enter code here
Upvotes: 0
Views: 120
Reputation: 373
findpeaks has a series of options to refine your results. In your case, the option 'MinPeakProminence' should work; it thresholds according to the prominence of a peak to its neighbors.
[pks,locs] = findpeaks(difference,'MinPeakProminence',0.25*max(difference))
Upvotes: 2