生成平滑的方波、三角波等

信息处理 平滑 吉布斯现象
2022-01-25 06:31:07

我试图获得描绘平滑版本的波形(三角形,方形,锯齿,反向锯齿)的函数,它们具有与相同的幅度和频率。cos(x)

我发现了一些描述这种波形的三角函数:

δ=0.05 ,

Squaresmooth=2.1tan1(sin(πx/3)/δ)/π

Trianglesmooth=1.255cos1((1δ)sin(πx/3.2))/(2π)

h=12.5 ,

Sawtoothsmooth=1.5+3((x/60.5)(tanh((((x/60.5)+0.5)(x/60.5)+0.50.5)h)/(2tanh(0.5h))+(x/60.5)+0.5)0.5))

但不幸的是,它们没有相同的幅度或频率。我认为可能适用于,但我仍在寻找修复的方法,有人有什么想法吗?cos(x)TrianglesmoothSquaresmoothSawtoothsmooth

2个回答

似乎幅度没有正确缩放。而不是 (2*A/pi) 使用 (A/atan(1/delta)) 似乎更合适。换句话说,我建议:

y = (A/atan(1/delta))*atan(sin(2*pi*t*f)/delta);

下图说明了两种缩放方法之间的差异。对于低值delta,差异并不明显,但对于高delta值,幅度会偏离所需的值。可以使用下面的 MATLAB 代码复制图像。

原始和调整功能的动画

t=linspace(0,2*pi,500);
delta = 0.1;
A = 1;
f = 1/(2*pi);
y1 = A*sin(2*pi*t*f);
y2 = (2*A/pi)*atan(sin(2*pi*t*f)/delta);
y3 = (A/atan(1/delta))*atan(sin(2*pi*t*f)/delta);

figure; hold on;
h1=plot(t,y1,'r-','LineWidth',5);
h2=plot(t,y2,'g-','LineWidth',4);
h3=plot(t,y3,'b-','LineWidth',2);
legend([h1 h2 h3],{'Sine','Smooth square wave','Corrected smooth square wave'},'Location','SouthOutSide');
axis tight; axis square;
set(gca,'FontSize',15); grid on; box on;
drawnow;

因此,“平滑”(可微分,没有吉布斯效应)方波可以定义为来源。)参数控制幅度,控制频率。例如,使用的 Matlab :

sss(t)=2Aπarctan[sin(2πtf)δ].
AfA=1.5f=2

t = 0:1/100:2;
delta = 0.01;
A = 1;
f = 2;
smoothsq = (2*A/pi)*atan(sin(2*pi*t*f)/delta);
plot(t,smoothsq);
axis([-0.2 2.2 -1.6 1.6]);

产生情节:

在此处输入图像描述

类似的东西应该适用于其他波形。