Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

MengFanjun的博客

在这里插入图片描述

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
clear
close all
clc

fs=1000;fc=200;fr=300;T=0.001;
wp1=2*pi*fc;
wr1=2*pi*fr;
[N1,wn1]=buttord(wp1,wr1,1,25,'s');
[B1,A1]=butter(N1,wn1,'s');
[num1,den1]=impinvar(B1,A1,fs);
[h1,w]=freqz(num1,den1);
wp2=2*fs*tan(2*pi*fc/(2*fs));
wr2=2*fs*tan(2*pi*fr/(2*fs));
[N2,wn2]=buttord(wp2,wr2,1,25,'s');
[B2,A2]=butter(N2,wn2,'s');
[num2,den2]=bilinear(B2,A2,fs);
[h2,w]=freqz(num2,den2);
f=w/(2*pi)*fs;
plot(f,20*log10(abs(h1)),'-.',f,20*log10(abs(h2)),'-');
axis([0,500,-80,10]);grid; xlabel('频率/Hz');ylabel('幅度/dB');title('巴特沃思数字低通滤波器'); legend('脉冲响应不变法','双线性变换法');
在这里插入图片描述

在这里插入图片描述
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
clear
close all
clc

wc=2*pi*1200;wr=2*pi*2000;rp=0.5;rs=40;fs=8000;
w1=2*fs*tan(wc/(2*fs));
w2=2*fs*tan(wr/(2*fs));
[Nb,wn]=buttord(w1,w2,rp,rs,'s');
[B,A]=butter(Nb,wn,'s');
[num1,den1]=bilinear(B,A,fs);
[h1,w]=freqz(num1,den1);
[Nc,wn]=cheb1ord(w1,w2,rp,rs,'s');
[B,A]=cheby1(Nc,rp,wn,'s');
[num2,den2]=bilinear(B,A,fs);
[h2,w]=freqz(num2,den2);
[Ne,wn]=ellipord(w1,w2,rp,rs,'s');
[B,A]=ellip(Ne,rp,rs,wn,'low','s');
[num3,den3]=bilinear(B,A,fs);
[h3,w]=freqz(num3,den3);
f=w/pi*4000;
plot(f,20*log10(abs(h1)),'-',f,20*log10(abs(h2)),'--',f,20*log10(abs(h3)),'-.' );
axis([0,3000,-100,10]);grid; xlabel('频率/Hz'); ylabel('幅度/dB'); title('三种数字低通滤波器');
legend('巴特沃思数字低通滤波器','切比雪夫数字低通滤波器','椭圆数字低通滤波器');

在这里插入图片描述 在这里插入图片描述

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
clear
close all
clc

wc=[2*pi*2000,2*pi*3000];wr=[2*pi*1500,2*pi*6000];rp=3;rs=20;fs=30000;
[N,wn]=buttord(wc,wr,rp,rs,'s');
[B,A]=butter(N,wn,'s');
[num1,den1]=impinvar(B,A,fs);
[h1,w]=freqz(num1,den1);
w1=2*fs*tan(2*pi*2000/(2*fs));
w2=2*fs*tan(2*pi*3000/(2*fs));
wr1=2*fs*tan(2*pi*1500/(2*fs));
wr2=2*fs*tan(2*pi*6000/(2*fs));
[N,wn]=buttord([w1,w2],[wr1,wr2],rp,rs,'s');
[B,A]=butter(N,wn,'s');
[num2,den2]=bilinear(B,A,fs);
[h2,w]=freqz(num2,den2);
f=w/pi*15000;
plot(f,20*log10(abs(h1)),'-.',f,20*log10(abs(h2)),'-');
axis([500,7000,-30,10]);
grid;
xlabel('频率/Hz');
ylabel('幅度/dB');
title('巴特沃思数字低通滤波器');
legend('脉冲响应不变法','双线性变换法');

在这里插入图片描述 在这里插入图片描述

1
2
3
4
5
6
7
8
9
10
clear
close all
clc

N=15;wn=[0.3,0.5];
window=hanning(N+1);
b=fir1(N,wn,window);
[H,w]=freqz(b);
subplot(2,1,1);plot(w/pi,20*log10(abs(H)));grid; xlabel('归一化频率');ylabel('幅度');title('幅频响应');
subplot(2,1,2);plot(w/pi,angle(H));grid; xlabel('归一化频率');ylabel('相位');title('相位响应');

在这里插入图片描述

1
2
3
4
5
6
7
8
9
10
clear
close all
clc

N=45;wn=[0.3,0.5];
window=hanning(N+1);
b=fir1(N,wn,window);
[H,w]=freqz(b);
subplot(2,1,1);plot(w/pi,20*log10(abs(H)));grid; xlabel('归一化频率');ylabel('幅度');title('幅频响应');
subplot(2,1,2);plot(w/pi,angle(H));grid; xlabel('归一化频率');ylabel('相位');title('相位响应');
在这里插入图片描述

在这里插入图片描述
1
2
3
4
5
6
7
8
9
10
11
clear
close all
clc

%矩形窗N=15

N=input('请输入 N 的值\n');wn=[0.3,0.5];
b=fir1(N,wn,boxcar(N+1));
[H,w]=freqz(b,1,512);
subplot(2,1,1);plot(w/pi,20*log10(abs(H)));grid; xlabel('归一化频率');ylabel('幅度');title('幅频响应');
subplot(2,1,2);plot(w/pi,angle(H));grid; xlabel('归一化频率');ylabel('相位');title('相频响应');
在这里插入图片描述
1
2
3
4
5
6
7
8
9
10
11
12
13
clear
close all
clc

%布莱克曼窗:(N=15 时)

N=input('请输入 N 的值\n');
wn=[0.3,0.5];
window=blackman(N+1);
b=fir1(N,wn,window);
[H,w]=freqz(b);
subplot(2,1,1);plot(w/pi,20*log10(abs(H)));grid; xlabel('归一化频率');ylabel('幅度');title('幅频响应');
subplot(2,1,2);plot(w/pi,angle(H));grid; xlabel('归一化频率');ylabel('相位');title('相频响应');
在这里插入图片描述

评论