低通滤波不能按预期工作

时间:2013-02-27 11:04:36

标签: matlab filter

以下Matlab脚本用于过滤由50 Hz和120 Hz正弦波组成的信号。我正在计算rad / s的频率为Fp =(2 * PI * 30)/1000=0.184。 我保持fp = 0.184和fst = 0.185,因为我想要滤除50赫兹和120赫兹。 但是当我绘制滤波器输出的FFT时,我得到的是50 Hz的正弦波。为什么这个50Hz的正弦值即使在滤波后也会出现?

理想情况下,情节中不应有任何峰值。

过滤前 enter image description here

过滤后

enter image description here

Fs = 1000;                    % Sampling frequency
T = 1/Fs;    % Sample time
L = 1000;                     % Length of signal
t =(0:L-1)*T;                % Time vector 
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);  % Sum of a 50 Hz sinusoid and a 120 Hz sinusoid %
y = x + 2*randn(size(t));     % Sinusoids plus noise

y = x ;

plot(Fs*t(1:50),y(1:50));title('Signal');xlabel('time (milliseconds)')

%pause;

NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1);

% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1))) 
title('Single-Sided Amplitude Spectrum of y(t)');xlabel('Frequency(Hz)');ylabel('|Y(f)|')


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Now let us see Low Pass Filtering of this signal  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Fp= (2*pi * 30)/1000; %=0.184 %only frequncies less than 30Hz will be passed  

d=fdesign.lowpass('Fp,Fst,Ap,Ast',0.184,0.185,2,60);

designmethods(d);

Hd = design(d,'equiripple'); fvtool(Hd);

Filterd_Output = filter(Hd,y);

NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Filtered_Freq = fft(Filterd_Output,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);

% Plot single-sided amplitude spectrum.
plot(f,2*abs(Filtered_Freq(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of Low Pass Filtered_Output')
xlabel('Frequency (Hz)');ylabel('|Filtered_Freq_Amplitude|')

更新 如我所建议,我将原始光谱与滤光光谱进行了比较。这解释了我很多。但是有什么方法可以让我在50赫兹的频率下进一步降低这个峰值吗?

1 个答案:

答案 0 :(得分:2)

您错误地指定了过滤器的标准化频率。 Matlab假设频率为[0,1],而不是[0,pi]。

替换

d=fdesign.lowpass('Fp,Fst,Ap,Ast',0.184,0.185,2,60);

d=fdesign.lowpass('Fp,Fst,Ap,Ast', 2*30/Fs, 2*35/Fs,2,60);

或者

d=fdesign.lowpass('Fp,Fst,Ap,Ast', 30, 35,2,60, Fs);

它应该按预期工作。

相关问题