kiss设计原则:fir1的用法

来源:百度文库 编辑:中财网 时间:2024/04/27 09:06:01
fir1的用法 
 调用MATLAB窗函数fir1设计实现带通滤波器。b=fir1(n,Wn),n表示滤波器的阶数。   %generate a compound signal s=s1+s2+s3  t=-1:.01:1;  s1=sin(2*pi*5*t);  s2=sinc(2*pi*25*t);  s3=cos(2*pi*40*t);  s=s1+s2+s3; %The compound signal 's' consists of three signal 's1','s2',s3'.  subplot(311);  plot(t,s);  grid;  axis([-1 1 -2 2]);  xlabel('time/second');  ylabel('time wave');  %generate a 100_order FIR bandpass filter,band width is 20Hz-30Hz.  b=fir1(100,[0.20 0.30]); %Use 'fir1' function for the bandpass filter designing.  [H,F]=freqz(b,1,512); %Compute the frequency response of discrete-time bandpass filters.  subplot(312);  plot(F*100/pi,20*log10(abs(H)));  grid;  axis([0 50 -100 0]);  xlabel('freqency/Hz');  ylabel('magnitude');  SF=filter(b,1,s); %Filter the desired signal 's2' from 's' with the finite impulse response (FIR) bandpass filter.  subplot(313);  plot(t,SF);  grid;  xlabel('time/Second');  ylabel('time wave');