測試**:
%filtercompare.m現象:低通濾波器%對比相同階數時四種iir濾波器的波紋特性
close all;
clear;
clc;
fs = 1000; %hz
%低通濾波器對比
n1 = 8;
wp = 50 / ( fs / 2);
ws = 100 / ( fs / 2);
alpha_p = 1;
alpha_s = 20;
[ b1,a1] = butter( n1 , ws , 'low' );
[ b2,a2] = cheby1( n1 , alpha_p , ws , 'low' );
[ b3,a3] = cheby2( n1 , alpha_s , ws , 'low' );
[ b4,a4] = ellip ( n1 , alpha_p,alpha_s , ws , 'low' );
[h1,w1] = freqz(b1,a1,1024*4);
[h2,w2] = freqz(b2,a2,1024*4);
[h3,w3] = freqz(b3,a3,1024*4);
[h4,w4] = freqz(b4,a4,1024*4);
w1 = w1/pi *fs/2;
w2 = w2/pi *fs/2;
w3 = w3/pi *fs/2;
w4 = w4/pi *fs/2;
figure(1);
plot(w1,abs(h1),'black','linewidth',0.5);
hold on;
plot(w2,abs(h2),'red','linewidth',0.5);
plot(w3,abs(h3),'green','linewidth',0.5);
plot(w4,abs(h4),'blue','linewidth',0.5);
xlim([0 500]);
ylim([0 1.1]);
legend();
title('同階數(n=8),同截止頻率(f_c=100hz)的低通濾波器對比');
%高通濾波器
n1 = 8;
wp = 400 / ( fs / 2);
ws = 400 / ( fs / 2);
alpha_p = 1;
alpha_s = 20;
[ b1,a1] = butter( n1 , ws , 'high' );
[ b2,a2] = cheby1( n1 , alpha_p , ws , 'high' );
[ b3,a3] = cheby2( n1 , alpha_s , ws , 'high' );
[ b4,a4] = ellip( n1 , alpha_p,alpha_s , ws , 'high' );
[h1,w1] = freqz(b1,a1,1024*4);
[h2,w2] = freqz(b2,a2,1024*4);
[h3,w3] = freqz(b3,a3,1024*4);
[h4,w4] = freqz(b4,a4,1024*4);
w1 = w1/pi *fs/2;
w2 = w2/pi *fs/2;
w3 = w3/pi *fs/2;
w4 = w4/pi *fs/2;
figure(2);
plot(w1,abs(h1),'black','linewidth',0.5);
hold on;
plot(w2,abs(h2),'red','linewidth',0.5);
plot(w3,abs(h3),'green','linewidth',0.5);
plot(w4,abs(h4),'blue','linewidth',0.5);
xlim([0 500]);
ylim([0 1.1]);
legend();
title('同階數(n=8),同截止頻率(f_c=400hz)的高通濾波器對比');
%帶通濾波器
n1 = 8;
wp = [ 100 , 400 ] / ( fs / 2);
ws = [ 100 , 400 ] / ( fs / 2);
alpha_p = 1;
alpha_s = 20;
[ b1,a1] = butter( n1 , ws , 'bandpass' );
[ b2,a2] = cheby1( n1 , alpha_p , ws , 'bandpass' );
[ b3,a3] = cheby2( n1 , alpha_s , ws , 'bandpass' );
[ b4,a4] = ellip( n1 , alpha_p,alpha_s , ws , 'bandpass' );
[h1,w1] = freqz(b1,a1,1024*4);
[h2,w2] = freqz(b2,a2,1024*4);
[h3,w3] = freqz(b3,a3,1024*4);
[h4,w4] = freqz(b4,a4,1024*4);
w1 = w1/pi *fs/2;
w2 = w2/pi *fs/2;
w3 = w3/pi *fs/2;
w4 = w4/pi *fs/2;
figure(3);
plot(w1,abs(h1),'black','linewidth',0.5);
hold on;
plot(w2,abs(h2),'red','linewidth',0.5);
plot(w3,abs(h3),'green','linewidth',0.5);
plot(w4,abs(h4),'blue','linewidth',0.5);
xlim([0 500]);
ylim([0 1.1]);
legend();
title('同階數(n=8),同截止頻率(f_c_1=100hz f_c_2 = 400hz)的帶通濾波器對比');
%帶阻濾波器
n1 = 8;
wp = [ 100 , 400 ] / ( fs / 2);
ws = [ 100 , 400 ] / ( fs / 2);
alpha_p = 1;
alpha_s = 20;
[ b1,a1] = butter( n1 , ws , 'stop' );
[ b2,a2] = cheby1( n1 , alpha_p , ws , 'stop' );
[ b3,a3] = cheby2( n1 , alpha_s , ws , 'stop' );
[ b4,a4] = ellip( n1 , alpha_p,alpha_s , ws , 'stop' );
[h1,w1] = freqz(b1,a1,1024*4);
[h2,w2] = freqz(b2,a2,1024*4);
[h3,w3] = freqz(b3,a3,1024*4);
[h4,w4] = freqz(b4,a4,1024*4);
w1 = w1/pi *fs/2;
w2 = w2/pi *fs/2;
w3 = w3/pi *fs/2;
w4 = w4/pi *fs/2;
figure(4);
plot(w1,abs(h1),'black','linewidth',0.5);
hold on;
plot(w2,abs(h2),'red','linewidth',0.5);
plot(w3,abs(h3),'green','linewidth',0.5);
plot(w4,abs(h4),'blue','linewidth',0.5);
xlim([0 500]);
ylim([0 1.1]);
legend();
title('同階數(n=8),同截止頻率(f_c_1=100hz f_c_2 = 400hz)的帶阻濾波器對比');
高通濾波器
帶通濾波器
帶阻濾波器
驗證結果:
1、巴特沃斯濾波器的通帶和阻帶均是單調製化,頻率響應最為平滑,若通帶邊緣滿足指標要求,則通帶內會有富餘量,並不經濟,更有效的方法是將指標的精度要求均勻分布在通帶或阻帶內,這樣能設計出階數較低的濾波器(意會,意會);
2、切比雪夫ⅰ型濾波器的幅度特性在通帶範圍內是等波紋的,在阻帶範圍內時單調的;
3、切比雪夫ⅱ型濾波器的幅度特性在阻帶範圍內是等波紋的,在通帶範圍內時單調的;
4、橢圓濾波器的幅度特性在通帶和阻帶範圍內均是等波紋的。
四種濾波器對比
按照逼近函式型別劃分,濾波器可分為 1 巴特沃斯濾波器 2 切比雪夫濾波器 3 貝塞爾濾波器 4 橢圓濾波器 巴特沃斯濾波器的特點是通頻帶內的頻率響應曲線最大限度平坦,沒有起伏,而在阻頻帶則逐漸下降為零。切比雪夫濾波器在過渡帶比巴特沃斯濾波器的衰減快,但頻率響應的幅頻特性不如後者平坦。切比雪夫濾波器...
FIR濾波器與IIR濾波器
有限長單位衝激響應濾波器,又稱為非遞迴型濾波器 特點 fir濾波器的最主要的特點是沒有反饋迴路,穩定性強,故不存在不穩定的問題 fir具有嚴格的線性相位,幅度特性隨意設定的同時,保證精確的線性相位 fir設計方式是線性的,硬體容易實現 fir相對iir濾波器而言,相同效能指標時,階次較高,對cpu的...
濾波器有幾種 四種濾波器之間對比詳解
轉至 如今的濾波器已經廣泛的滲透到來日常的生活中。那麼最常用的四種濾波器是那種呢?它主要分為哪四類?就目前來說,最經典的數字濾波器有巴特沃斯濾波器 切比雪夫濾波器 橢圓濾波器和貝塞爾濾波器。巴特沃斯濾波器的特點是通頻帶內的頻率響應曲線最大限度平坦,沒有起伏,而在阻頻帶則逐漸下降為零。在振幅的對數對角...