我在MATLAB中为Chebyshev 1型滤波器编写了代码,以滤除不需要的频率,但是,当将滤波器的下限截止频率从0.1Hz更改为1Hz时,会有一个奇怪的冲动。当我将相同的截止频率更改为2时,脉冲消失了。 此cheby1滤波器的带阻频率为:最低频率为0.001,最高频率为15Hz。 此外,我在时域中绘制了功率谱密度(PSD),幅度和滤波后的数据(图(4))。谁能告诉我为什么在时域中(底图(4))看起来像是一时冲动打我的数据?
我正在尝试以2至4 Hz的非常低的频率过滤信号,并且我无法摆脱幅度图中的奇怪脉冲,因此我的数据看起来像是旁边有一个凸起。任何对书籍的引用或任何引用都将不胜感激。
%% We plot time domain of signal with different frequencies.
% The sine+noise signal
Fs=1000; %sampling frequency in Hz
tiv=1/Fs; %time interval between samples;
t=0:tiv:(50-tiv); %time intervals set (200 values)
N=length(t); %number of data points
yr=randn(N,1); %random signal data set
% Frequencies in the signal (Hz)
freq = 60;freq_2 = 20;freq_3 = 12;freq_4 = 2;freq_5 = 18;
amp = 2;
%Sinusoidals at different frequencies
sig_1 = amp*sin(2*pi*freq*t);sig_2 = amp*sin(2*pi*freq_2*t);
sig_3 = 1*sin(2*pi*freq_3*t);sig_4 = 1*cos(2*pi*freq_4*t);
sig_5 = amp*sin(2*pi*freq*t);sig_6 = amp*sin(freq_5*2*pi*t);
%All different signals added into one
y=sig_6 + sig_5 + sig_4 + sig_3 + sig_2 + sig_1 + yr'; %the signal+noise
figure(1)
plot(t,y,'k'); %plots sine+noise
xlabel('seconds'); title('sine+noise signal');
title('Time domain of a mix of signals')
%-------------------------------------------------------------------------
%% PWELCH PSD Method
figure(2)
% Power spectral density (PSD) we can see the frequencies in our noise
nfft = 2^16; %length of FFT
window = hanning(1536); %window function
numoverlap = 128; %number of samples overlap
pwelch(y, window, numoverlap, nfft, Fs);
xlim([0 80])
title('PSD of a sine+noise signal. We see our sinusoidals');
%% We run signal through filter
hp = 0.1; lp = 3;
Wp = [hp lp]/(Fs/2);
Ws= [.001 10]/(Fs/2);
Rp = 0.5; % passband ripple
Rs = 40; % stop band attenuation
[n, Wp] =cheb1ord(Wp, Ws, Rp, Rs)
% Chebyshev filter DO NOT DELETE
[z,p,k] = cheby1(n, Rp,Wp); %Cheby1 Rp = 0.5
[sos,g] = zp2sos(z,p,k);
cheby1Filt = filtfilt(sos, g, y);
cheby1Filt = cheby1Filt - mean(cheby1Filt); % Subtracting the mean to block DC Component
%%
%FFT of the filtered signal
NFFT = length(cheby1Filt);
data_out_freq = fft(cheby1Filt, NFFT);
freq = ((0:1/NFFT:1-1/NFFT)*Fs).';
data_out_freq = data_out_freq - mean(data_out_freq);
data_out_mag = abs(data_out_freq);
figure(4)
% Power spectral density (PSD) of a signal+noise
subplot(3,1,1)
nfft = 2^16; %length of FFT
window = hanning(4024); %window function
numoverlap = 128; %number of samples overlap
pwelch(cheby1Filt, window, numoverlap, nfft, Fs);
xlim([0 10]);
title('Cheby 1 Hamming window Power Spectral Density (PSD)');
subplot(3,1,2)
plot(freq, data_out_mag, 'b');
title('Cheby 1 Filter 0.5dB ripple')
ylabel('Magnitude');
xlabel('Frequency (Hz)');
xlim([0 10]);
subplot(3,1,3)
plot(cheby1Filt, 'r');
title('Cheby 1Filtered data in time domain')
ylabel('Amp');
xlabel('Time)');
我希望过滤掉不需要的频率而不会出现在幅度图中看到的脉冲。