How to prevent envelope crossing through function.

1 回表示 (過去 30 日間)
Ali
Ali 2019 年 7 月 10 日
回答済み: Akira Agata 2019 年 7 月 11 日
How can you stop the envelope of a sinc function crossing the function. I would like it to just skim the maxima points as shown by the drawn envelope in Sinc_envelope.jpg attached.
x = linspace(-20,20,500);
y = abs(sin(x)./(x)).*abs(sin(x)./(x));
[up,lo]=envelope(y,1,'peak');
plot(x,y)
hold on
%plot(x,up)
plot(x,up)

採用された回答

Akira Agata
Akira Agata 2019 年 7 月 11 日
That is due to a characteristics of interpolation method (Spline) used in the envelope function. How about detecting peaks and interpolate them by "Shape-preserving piecewise cubic" ? The following is an example.
x = linspace(-20,20,500);
y = abs(sin(x)./(x)).*abs(sin(x)./(x));
[pk,loc] = findpeaks(y,x);
y2 = interp1(loc,pk,x,'pchip');
plot(x,y)
hold on
plot(x,y2)
legend({'Original','Envelope'},'FontSize',14)
envelope.png

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by