低通fp=1000;fc=1200;As=100;Ap=1;Fs=3000;wc=2*pi*fc/Fs; wp=2*pi*fp/Fs;wd=wc-wp;beta=0.1102*(As-8.7);N=ceil((As-7.95)/2.286/wd);wn= kaiser(N+1,beta); ws=(wp+wc)/2/pi;b=fir1(N,ws,wn);figure(1);freqz(b,1);x=fftfilt(b,y);X=fft(x);figure(2);subplot(2,2,1);plot(abs(Y1));axis([0,2000,0,100.0]);title("濾波前訊號頻譜");subplot(2,2,2);plot(abs(X));axis([0,2000,0,100.0]);title("濾波後訊號頻譜");subplot(2,2,3);plot(y);title("濾波前訊號波形");subplot(2,2,4);plot(x);title("濾波後訊號波形");sound(x,fs,bits);帶通fp1=1200 ;fp2=3000 ;fc1=1000 ;fc2=3200 ;As=100 ;Ap=1 ;Fs=35000 ;wp1=2*pi*fp1/Fs; wc1=2*pi*fc1/Fs; wp2=2*pi*fp2/Fs; wc2=2*pi*fc2/Fs;wdel=wp1-wc1;beta=0.1102*(As-8.7);N=ceil((As-7.95)/2.286/wdel);ws =[(wp1+wc1)/2/pi,(wp2+wc2)/2/pi];wn= kaiser(N+1,beta); b=fir1(N,ws,wn);figure(1); freqz(b,1)x=fftfilt(b,z1);X=fft(x);figure(2);subplot(2,2,1);plot(abs(Y1));axis([0,2000,0,50.0]);title("濾波前訊號頻譜");subplot(2,2,2);plot(abs(X));axis([0,2000,-1.0,1.0]);title("濾波後訊號頻譜")subplot(2,2,3);plot(z1);title("濾波前訊號波形");subplot(2,2,4);plot(x);title("濾波後訊號波形");sound(x,fs,bits);高通fp=4800;fc=5000;As=100;Ap=1;Fs=200000;wc=2*pi*fc/Fs; wp=2*pi*fp/Fs;wdel=wc-wp;beta=0.1102*(As-8.7);N=ceil((As-7.95)/2.286/wdel);wn= kaiser(N,beta); ws=(wp+wc)/2/pi;b=fir1(N-1,ws,"high",wn);figure(1);freqz(b,1);x=fftfilt(b,z1);X=fft(x);figure(2);subplot(2,2,1);plot(abs(Y1));axis([0,2000,0,50.0]);title("濾波前訊號頻譜");subplot(2,2,2);plot(abs(X));axis([0,2000,-1.0,1.0]);title("濾波後訊號頻譜");subplot(2,2,3);plot(z1);title("濾波前訊號波形");subplot(2,2,4);plot(x);title("濾波後訊號波形");sound(x,fs,bits);
低通fp=1000;fc=1200;As=100;Ap=1;Fs=3000;wc=2*pi*fc/Fs; wp=2*pi*fp/Fs;wd=wc-wp;beta=0.1102*(As-8.7);N=ceil((As-7.95)/2.286/wd);wn= kaiser(N+1,beta); ws=(wp+wc)/2/pi;b=fir1(N,ws,wn);figure(1);freqz(b,1);x=fftfilt(b,y);X=fft(x);figure(2);subplot(2,2,1);plot(abs(Y1));axis([0,2000,0,100.0]);title("濾波前訊號頻譜");subplot(2,2,2);plot(abs(X));axis([0,2000,0,100.0]);title("濾波後訊號頻譜");subplot(2,2,3);plot(y);title("濾波前訊號波形");subplot(2,2,4);plot(x);title("濾波後訊號波形");sound(x,fs,bits);帶通fp1=1200 ;fp2=3000 ;fc1=1000 ;fc2=3200 ;As=100 ;Ap=1 ;Fs=35000 ;wp1=2*pi*fp1/Fs; wc1=2*pi*fc1/Fs; wp2=2*pi*fp2/Fs; wc2=2*pi*fc2/Fs;wdel=wp1-wc1;beta=0.1102*(As-8.7);N=ceil((As-7.95)/2.286/wdel);ws =[(wp1+wc1)/2/pi,(wp2+wc2)/2/pi];wn= kaiser(N+1,beta); b=fir1(N,ws,wn);figure(1); freqz(b,1)x=fftfilt(b,z1);X=fft(x);figure(2);subplot(2,2,1);plot(abs(Y1));axis([0,2000,0,50.0]);title("濾波前訊號頻譜");subplot(2,2,2);plot(abs(X));axis([0,2000,-1.0,1.0]);title("濾波後訊號頻譜")subplot(2,2,3);plot(z1);title("濾波前訊號波形");subplot(2,2,4);plot(x);title("濾波後訊號波形");sound(x,fs,bits);高通fp=4800;fc=5000;As=100;Ap=1;Fs=200000;wc=2*pi*fc/Fs; wp=2*pi*fp/Fs;wdel=wc-wp;beta=0.1102*(As-8.7);N=ceil((As-7.95)/2.286/wdel);wn= kaiser(N,beta); ws=(wp+wc)/2/pi;b=fir1(N-1,ws,"high",wn);figure(1);freqz(b,1);x=fftfilt(b,z1);X=fft(x);figure(2);subplot(2,2,1);plot(abs(Y1));axis([0,2000,0,50.0]);title("濾波前訊號頻譜");subplot(2,2,2);plot(abs(X));axis([0,2000,-1.0,1.0]);title("濾波後訊號頻譜");subplot(2,2,3);plot(z1);title("濾波前訊號波形");subplot(2,2,4);plot(x);title("濾波後訊號波形");sound(x,fs,bits);