is there's a way to automatically find peaks in an histogram?
62 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sani
el 28 de Mayo de 2020
Comentada: sani
el 30 de Mayo de 2020
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/304871/image.jpeg)
2 comentarios
Respuesta aceptada
Steven Lord
el 29 de Mayo de 2020
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 comentarios
Image Analyst
el 29 de Mayo de 2020
How is islocalmax() different than findpeaks()? Is it just that it's in base MATLAB instead of the Signal Processing Toolbox?
Más respuestas (0)
Ver también
Categorías
Más información sobre Spectral Estimation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!