FIR數字濾波器的設計

2022-12-10 03:21:04 字數 5221 閱讀 5587

實驗報告

專業班級電科0803姓名班雙江

學號 200848360304 實驗名稱 fir數字濾波器的設計

一、實驗目的:

設計fir數字濾波器

二、實驗內容:

設計乙個帶通fir數字濾波器,設計指標:通帶衰減1db,阻帶衰減40db,通帶截止頻率:500hz,700hz;阻帶截止頻率:

400hz,800hz;抽樣頻率:2000hz。

1、使用hamming窗函式:

matlab程式:

% program p7_5_1

% design of a bandpass fir digital filter

clc;clear all;

rp = 1; % bandpass attenuation in db

rs = 40; % bandstop attenuation in db

omegap1_1=500; % bandpass edge frequency

omegap1_2=700; % bandpass edge frequency

omegas1_1=400; % bandstop edge frequency

omegas1_2=800; % bandstop edge frequency

ft=2000; % samling frequency

fp=[omegap1_1 omegap1_2];

fs=[omegas1_1 omegas1_2];

deta_p=1-10^(-rp/20);

deta_s=10^(-rs/20);

% estimate the filter order

n = kaiord(fp, fs, deta_p, deta_s, ft);

% design the filter

wn=2/ft*[omegap1_1 omegap1_2];% normalize the frequency,ft/2 correspond to pi(normalize 1 correspond pi)

b=fir1(n,wn,'bandpass',hamming(n+1));

% compute the gain response

[g, w] = gain(b,1);

% plot the gain response

plot(w/pi,g);grid

axis([0 1 -60 5]);

xlabel('\omega /\pi'); ylabel('gain in db');

title('gain response of a fir bandpass filter');

執行結果

可以看出ω/π=0.4時衰減為25.5644;ω/π=0.

5時衰減為5.0733;ω/π=0.7時衰減為5.

0624;ω/π=0.8時衰減為25.7568。

不符合設計標準。

增加n值為1000:

% program p7_5_2

% design of a bandpass fir digital filter

clc;clear all;

rp = 1; % bandpass attenuation in db

rs = 40; % bandstop attenuation in db

omegap1_1=500; % bandpass edge frequency

omegap1_2=700; % bandpass edge frequency

omegas1_1=400; % bandstop edge frequency

omegas1_2=800; % bandstop edge frequency

ft=2000; % samling frequency

fp=[omegap1_1 omegap1_2];

fs=[omegas1_1 omegas1_2];

deta_p=1-10^(-rp/20);

deta_s=10^(-rs/20);

% estimate the filter order

%n = kaiord(fp, fs, deta_p, deta_s, ft);

n=1000;

% design the filter

wn=2/ft*[omegap1_1 omegap1_2];% normalize the frequency,ft/2 correspond to pi(normalize 1 correspond pi)

b=fir1(n,wn,'bandpass',hamming(n+1));

% compute the gain response

w = 0:pi/255:pi;

h = freqz(b,1,w);

g = 20*log10(abs(h));

% plot the gain response

plot(w/pi,g);grid

axis([0 1 -60 5]);

xlabel('\omega /\pi'); ylabel('gain in db');

title('gain response of a fir bandpass filter');

w1=[0.4*pi,0.5*pi,0.7*pi,0.8*pi];

h1=freqz(b,1,w1);

g1=-20*log10(abs(h1));

執行結果:

可以看出ω/π=0.4時衰減為78.5233;ω/π=0.

5時衰減為6.0191;ω/π=0.7時衰減為6.

0191;ω/π=0.8時衰減為78.2051。

通帶衰減不符合設計標準。

2、使用hanning窗函式

% program p7_5

% design of a bandpass fir digital filter

clc;clear all;

rp = 1; % bandpass attenuation in db

rs = 40; % bandstop attenuation in db

omegap1_1=500; % bandpass edge frequency

omegap1_2=700; % bandpass edge frequency

omegas1_1=400; % bandstop edge frequency

omegas1_2=800; % bandstop edge frequency

ft=2000; % samling frequency

fp=[omegap1_1 omegap1_2];

fs=[omegas1_1 omegas1_2];

deta_p=1-10^(-rp/20);

deta_s=10^(-rs/20);

% estimate the filter order

n = kaiord(fp, fs, deta_p, deta_s, ft);

%n=1000;

% design the filter

wn=2/ft*[omegap1_1 omegap1_2];% normalize the frequency,ft/2 correspond to pi(normalize 1 correspond pi)

b=fir1(n,wn,'bandpass',hanning(n+1));

% compute the gain response

w = 0:pi/255:pi;

h = freqz(b,1,w);

g = 20*log10(abs(h));

% plot the gain response

plot(w/pi,g);grid

axis([0 1 -60 5]);

xlabel('\omega /\pi'); ylabel('gain in db');

title('gain response of a fir bandpass filter');

w1=[0.4*pi,0.5*pi,0.7*pi,0.8*pi];

h1=freqz(b,1,w1);

g1=-20*log10(abs(h1));

可以看出ω/π=0.4時衰減為26.8170;ω/π=0.

5時衰減為5.2486;ω/π=0.7時衰減為5.

2501;ω/π=0.8時衰減為26.7749。

通帶衰減與阻帶衰減均不符合設計標準。

將n值改為1000:

% program p7_5

% design of a bandpass fir digital filter

clc;clear all;

rp = 1; % bandpass attenuation in db

rs = 40; % bandstop attenuation in db

omegap1_1=500; % bandpass edge frequency

omegap1_2=700; % bandpass edge frequency

omegas1_1=400; % bandstop edge frequency

omegas1_2=800; % bandstop edge frequency

ft=2000; % samling frequency

fp=[omegap1_1 omegap1_2];

fs=[omegas1_1 omegas1_2];

deta_p=1-10^(-rp/20);

deta_s=10^(-rs/20);

% estimate the filter order

%n = kaiord(fp, fs, deta_p, deta_s, ft);

n=1000;

% design the filter

wn=2/ft*[omegap1_1 omegap1_2];% normalize the frequency,ft/2 correspond to pi(normalize 1 correspond pi)

b=fir1(n,wn,'bandpass',hanning(n+1));

% compute the gain response

w = 0:pi/255:pi;

h = freqz(b,1,w);

g = 20*log10(abs(h));

% plot the gain response

plot(w/pi,g);grid

axis([0 1 -60 5]);

第五章FIR數字濾波器設計

5.2.6 matlab實現fir窗函式設計法 在matlab訊號處理工具箱中,matlab提供了幾個子程式來實現上面的窗函式,同時還提供了兩個基於窗函式法的fir數字濾波器設計函式b fir1 n,wn,options 和b fir2 n,f,m,options 前者用於單帶fir濾波器,後者用於...

數字濾波器設計小結

胡永波數字濾波器簡介 濾波器可廣義的理解為乙個訊號選擇系統,它讓某些訊號成分通過又阻止或衰減另一些成分。在更多的情況下,濾波器可理解為選頻系統,如低通 高通 帶通 帶阻。當然我們無法做到理想情況下的低通 高通 帶通 帶阻,這樣對於設計濾波器我們邊有乙個設計目標或者說設計指標,以低通濾波器為例。數字濾...

實驗三參考IIR數字濾波器的設計

一 實驗目的 1 掌握雙線性變換法及脈衝相應不變法設計iir數字濾波器的具體設計方法 2 熟悉用雙線性變換法及脈衝響應不變法設計低通 高通和帶通iir數字濾波器的計算機程式設計。二 實驗原理 在matlab中,可以用下列函式輔助設計iir數字濾波器 1 利用buttord和cheb1ord可以確定低...