is there's a way to automatically find peaks in an histogram?

조회 수: 77 (최근 30일)
sani 2020년 5월 28일
댓글: sani 2020년 5월 30일
Hello,
I have a script to analyze data from a detector (the data is not necessarily repeated). right now I have to find the peaks manually which is time-consuming!
is there's a way I can get the range of the peak base in the x-axis automatically? and is there's a way to neglect small peaks (let's say small in respect to the ratio from the max peak)?
here is an example of histogram I'm working with
댓글 수: 2없음 표시없음 숨기기
Rik 2020년 5월 28일
Have you tried the findpeaks function?
sani 2020년 5월 28일
yes but I couldn't applied it for histogram, just to my original data (and it dosn't relevant)

댓글을 달려면 로그인하십시오.

채택된 답변

Steven Lord 2020년 5월 29일
You can do this using the islocalmax function.
% Sample data
rng default
x = randn(1, 1e5);
h = histogram(x);
% Retrieve some properties from the histogram
V = h.Values;
E = h.BinEdges;
% Use islocalmax
L = islocalmax(V);
% Find the centers of the bins that islocalmax identified as peaks
left = E(L);
right = E([false L]);
center = (left + right)/2;
% Plot markers on those bins
hold on
plot(center, V(L), 'o')
댓글 수: 4이전 댓글 2개 표시이전 댓글 2개 숨기기
Image Analyst 2020년 5월 29일
How is islocalmax() different than findpeaks()? Is it just that it's in base MATLAB instead of the Signal Processing Toolbox?
sani 2020년 5월 30일
thanks a lot Steven! it was really helpful:)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by