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

83 ビュー (過去 30 日間)
sani
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
Rik 2020 年 5 月 28 日
Have you tried the findpeaks function?
sani
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
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 件のコメント
Image Analyst
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
sani 2020 年 5 月 30 日
thanks a lot Steven! it was really helpful:)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by