Findpeaks with multiple columns

8 views (last 30 days)
HC98
HC98 on 14 Feb 2022
Answered: Star Strider on 16 Feb 2022
So I have an array which is sized at 2000 x 100, called bdata. I want to use findpeaks to determine the peaks in every column of this array. I tried the following:
for g = 2:size(bdata,2)
[pk,loc] = findpeaks(bdata(:,g));
P{g} = [pk loc];
end
But it keeps calculating wrong values and even values not in bdata...
  2 Comments
Mathieu NOE
Mathieu NOE on 14 Feb 2022
hello
can you share the data as well and explain what you expect ?
Mathieu NOE
Mathieu NOE on 16 Feb 2022
hello
so , problem solved ?

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 16 Feb 2022
I am not certain what the data are, and without the data an appropriate solution is not possible.
However, there are two observations:
1. The findpeaks call in the question will return the indices of the peaks, not the independent variable value corresponding to those peaks. Finding that however is straightforward — simply use the ‘locs’ result to index into it.
2. The easiest way to be certain that findpeaks returns the desired peak is to use one or more of the name-value pair arguments. The one I use most is 'MinPeakProminence' since it invariably works and is relatively independent of the actual peak height. The 'MinPeakDistance' name-value pair can also help isolate the correct peak.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!