我将巴特沃斯滤波器用于方脉冲和正弦波。在方波脉冲的情况下,对于不同的巴特沃斯阶 (wn > 2),巴特沃斯会在时域中产生一些方波边缘的尖锐波纹。但是在正弦波的情况下,我看不到任何波纹。谁能解释一下这背后的原因?Matlab 代码与情节一起跟随。
close all
clear all
T = 1/10;
t = linspace(0,T,1001);
s = square (2*pi*100*t);
fs=10/200; % sampling frequency
fc=0.2; % fc normalized
offset=0;
amp=3.3;
duty=50;
t=0:0.01:100;%100 seconds
sq_wav=offset+amp*square(2*pi*fs.*t,duty);
sin_wav = offset + amp*sin(2*pi*fs.*t);
disp(length(sin_wav));
N = length(sq_wav);
disp(N);
#disp(t(1:10));
t1 = [0:N-1];
disp(t1(1:10));
disp(fs);
wn = 15; % filter order
[b,a] = butter(wn, fc);
[h,w] = freqz(b,a);
out_sq = filter(b,a,sq_wav);
out_sin = filter(b,a,sin_wav);
subplot (4, 1, 1)
plot(t(1:end),sq_wav(1:end))
title("square pulse");
subplot (4, 1, 2)
plot(t(1:end),sin_wav(1:end))
title("sine pulse");
subplot (4, 1, 3)
plot(t(1:end),out_sq(1:end))
title("square pluse after butterworth");
subplot (4, 1, 4)
plot(t(1:end),out_sin(1:end))
title("sine pluse after butterworth");
这是此代码的输出:





