Count the number of "aggregate" peaks in a vector?
Show older comments
I have some data in a vector in matlab called voltage collected from a sound sensor. When plotted against a time vector containing every instant of time these values were recorded at, I get the figure below:

As you can see, the data is "spikey" but there are some "spikes" that clearly larger and more noticesable than the surrounding - here I can count 10 of them. The sensor recorded sounds from a nearby buzzer - when the buzzer was silent, the voltage stayed at (around) the midway level (2.5V) but when it buzzed, it jumped to 5V, then to 0V and back, resulting in these larger spikes. This means that the buzzer beeped 10 times.
I want to count the number of these larger spikes which will tell me the number of times, the buzzer beeped.
- My first thought was to set some arbitrary threshold like 5V and do a linear search of the voltage vector to check how many samples reached 5V but there were many samples within the same peak that did this - so that would be overcounting.
- I also tried using the findpeaks functions which unfortunately also counts local maxima and returned many false positives even in the noisy regions around 2.5V where the buzzer is supposed to be silent.
Is there any good way to go about this? I am struggling to figure out what mathematical approach to take to analyse this. I have attached the .mat file containing the voltage and time vectors. Any help is appreciated. Thanks!
Accepted Answer
More Answers (1)
the cyclist
on 23 Jul 2022
1 vote
I am absolutely positively NOT an expert in this, but I think what might be helpful here is putting your signal through a low-pass filter. (You need the Signal Processing Toolbox for that.)
1 Comment
Shovnik Paul
on 24 Jul 2022
Categories
Find more on Descriptive Statistics 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!