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.