Findpeaks with multiple columns

2 次查看(过去 30 天)
HC98
HC98 2022-2-14
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 个评论
Mathieu NOE
Mathieu NOE 2022-2-14
hello
can you share the data as well and explain what you expect ?

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2022-2-16
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.

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by