MATLABで包絡線を描く方法

次のファイルをダウンロードする。
Envelope 1.1
https://jp.mathworks.com/matlabcentral/fileexchange/3142-envelope1-1 (https://jp.mathworks.com/matlabcentral/fileexchange/3142-envelope1-1)

実行例

x=linspace(0,2*pi,2000);
y=exp(-x).*sin(20*x);
[up,down] = envelope(x,y,'linear');
plot(x,y)
hold all
plot(x,up)
plot(x,down)

f:id:imakov:20211010214511p:plain