低通滤波器
请问各位高手,用matlab怎么做低通滤波的方针?求详细过程,有图更好,谢谢!! 简单的方法是用fdatool工具,根据你信号的参数填写相关参数生成一个滤波器,保存.m文件http://cache.amobbs.com/bbs_upload782111/files_48/ourdev_701524S2LKQT.jpg
(原文件名:1.jpg)
生成的滤波器文件如下filter.m
function Hd = filter
%FILTER1 Returns a discrete-time filter object.
%
% M-File generated by MATLAB(R) 7.8 and the Signal Processing Toolbox 6.11.
%
% Generated on: 04-Dec-2011 18:16:39
%
% Equiripple Lowpass filter designed using the FIRPM function.
% All frequency values are in Hz.
Fs = 500;% Sampling Frequency
Fpass = 10; % Passband Frequency
Fstop = 20; % Stopband Frequency
Dpass = 0.057501127785;% Passband Ripple
Dstop = 0.0001; % Stopband Attenuation
dens= 20; % Density Factor
% Calculate the order from the parameters using FIRPMORD.
= firpmord(/(Fs/2), , );
% Calculate the coefficients using the FIRPM function.
Hd= firpm(N, Fo, Ao, W, {dens});
%Hd = dfilt.dffir(b);
%
测试程序如下
Fs = 500; % Sampling frequency
T = 1/Fs; % Sample time
L = 500; % Length of signal
t = (0:L-1)*T; % Time vector
x=sin(2*pi*10*t)+0.4*sin(2*pi*250*t)+0.2*sin(2*pi*100*t)+0.7*sin(2*pi*50*t)+0.5*sin(2*pi*150*t);
plot(Fs*t(1:L),x(1:L))
title('滤波前时域信号')
xlabel('t')
ylabel('y(t)')
figure;
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(x,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('滤波前单边谱幅度')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
figure;
out=fftfilt(filter1,x);
plot(Fs*t(1:L),out(1:L));
title('滤波后时域信号')
xlabel('t')
ylabel('y(t)')
figure;
Y = fft(out,NFFT)/L;
% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1)))
title('滤波后单边谱幅度')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
测试图如下
http://cache.amobbs.com/bbs_upload782111/files_48/ourdev_701525FVEF83.jpg
(原文件名:2.jpg)
http://cache.amobbs.com/bbs_upload782111/files_48/ourdev_701526RJQVOJ.jpg
(原文件名:3.jpg)
http://cache.amobbs.com/bbs_upload782111/files_48/ourdev_701527R6J1H6.jpg
(原文件名:4.jpg)
http://cache.amobbs.com/bbs_upload782111/files_48/ourdev_701528AY6R5Q.jpg
(原文件名:5.jpg)
从图中可以看出高频信号已经被滤去了只剩下低频信号,这里只是随便做的一个演示,具体滤波器需要根据你的信号来设计 回复【1楼】s200661524
-----------------------------------------------------------------------
谢谢 回复【1楼】s200661524
-----------------------------------------------------------------------
为什么figure3、4都显示不出来啊? {:lol:}{:lol:}{:lol:}{:lol:}{:lol:}{:lol:}{:lol:}{:lol:}{:lol:}
页:
[1]