필터 지우기
필터 지우기

How to find maximum among several local peaks?

조회 수: 19 (최근 30일)
Ying Wu
Ying Wu 2022년 11월 14일
댓글: Star Strider 2022년 11월 14일
Hi, I use findpeaks() to locate a few local maxima of a data array as the data may flucuate slightly when closing peak, like the figure below. The third peak in red box is the largest one in value, how can I just locate the thrid one among five peaks in matlab? Thanks!

채택된 답변

Star Strider
Star Strider 2022년 11월 14일
It would help to have the data.
If that is the maximum peak in value, it is also the maximum of the vector plotted in the image.
One way to return it and its index, if the independent variable vector is ‘v’, is simply:
[vmax, idx] = max(v)
Otherwise, iif that is not appropriate and if you know that the third peak is the one you want to return, this may work:
[pks,locs] = findpeaks(v)
peak3 = pks(3)
locs3 = locs(3)
There may be other ways to isolate it, however without the data, it is not possible to determine that.
.
  댓글 수: 2
Ying Wu
Ying Wu 2022년 11월 14일
@Star Strider Thanks for reply! The data is like a periodic sine-plot, and will slightly up and down when closing each peak. And I'd like to determine the maximum for each peak among a few values. For now, my method is to use findpeaks() to determine several values for each peak, and divid them into different group accoding to the index, and then choose maximum and its index of each group, so that there would be only one maximum value around each peak. But this method is a little bit tedious, so I am wondering whether matlab has embedded function to solve similar problems. Thanks again!
Star Strider
Star Strider 2022년 11월 14일
As always, my pleasure!
If you want a specific number of maxima, rather than using findpeaks, you can use the maxk function (introduced in R2017b).
You can also use maxk with the findpeaks results.
II’m not certain which would be best, because I’m not certain what you want to do.
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by