MATLAB Answers

finding peaks at distances for curve with certain samples

1 view (last 30 days)
MatG
MatG on 3 Apr 2020
Edited: Tommy on 3 Apr 2020
I have a curve (X-Y) which has its absolute maximum at X=0 and the curve extends (and declines in terms of Y value) to right/left of the X=0. The curve has a lot of lobes and it is a very long vector of Y-values, but it has many local maxima. I want to obtain an envelop of the curve with only 2001 samples with 1 sample at X= 0, 1000 samples at left and 1000 samples on right so that these are an approximate envelop of the curve.
I use the envelope(Y, 2000,'peak') to extract the samples which is slow. Is there any other suggestions to obtain a vector [Z_1,...,Z_2001] such that:
1) Z_1001 is the maximum of curve Y (which is usually in its middle at X=0).
2) Z_1 through Z_1000 be 1000 samples of maximums to form an envelop above the curve for X<0.
3) Z_1002 through Z_20001 be the 1000 samples of Y which form an envelop above curve for X>0.

  1 Comment

Tommy
Tommy on 3 Apr 2020
You may consider using
[TF,P] = islocalmax(Y)
where TF will have the same length as Y and will contain a 1 (true) where a local maximum is detected, and P (also the same length as Y) gives the prominence of each peak, which "measures how the peak stands out with respect to its height and location relative to other peaks" (https://www.mathworks.com/help/matlab/ref/islocalmax.html). P is 0 for any point not considered a local maximum. Then,
[~, i] = maxk(P(X>0), 1000);
should give the indices in Y of the 1000 'best' maxima for X>0.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!