巴特沃斯带阻数字滤波器设计matlab程序及仿真图

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

fs=15000;T= 1/fs;

rp=1;rs=40;

wp1=0.11*pi;wp2=0.81*pi;ws1=0.31*pi;ws2=0.61*pi;%数字带阻滤波器技术指标wc1=(2/T)*tan(wp1/2);%频率预畸变

wc2=(2/T)*tan(wp2/2);wr1=(2/T)*tan(ws1/2);wr2=(2/T)*tan(ws2/2);

w0=sqrt(wc1*wc2);B=wc2-wc1;

wp=1;%归一化通带截止频率

ws=wp*(wr1*B) / (w0^2-wr1^2) ; %归一化阻带截止频率

[N,wc]=buttord(wp,ws,rp,rs,'s')%求滤波器阶数和3dB截止频率

[Z,P,K]=buttap(N)%设计模拟低通滤波器

[Md,Nd]=zp2tf(Z,P,K)%将零极点形式转换为传输函数形式

[M,N]=lp2bs(Md,Nd,w0,B)%对低通滤波器进行频率变换,转换为带阻滤波器[h,w]=freqs(M,N);%模拟带阻滤波器的幅频响应

plot(w/(2*pi),abs(h));grid;

xlabel('频率Hz');ylabel('幅度');title('模拟带阻滤波器');

[b,a]=bilinear(M,N,15000)%对模拟滤波器双线性变换

figure(1);

freqz(b,a);[H,W]=freqz(b,a); %绘出频率响应;

axis([0,1,-100,20]);

figure(2);

plot(W*fs/(2*pi),abs(H));grid on;

xlabel('频率/Hz');

ylabel('幅值');

n=0:199;t=n/fs;

x=sin(2*pi*400*t)+3*sin(2*pi*3000*t)+2*sin(2*pi*5000*t);

figure(3);

subplot(311);plot(t,x);axis([0,0.01,-5,5]);

title('输入信号');grid on;

y=filter(b,a,x);

subplot(312);stem(y,'.');title('输出序列');grid on;

ya=y*sinc(fs*(ones(length(n),1)*t-(n/fs)'*ones(1,length(t))));

subplot(313);plot(t,ya);axis([0,0.01,-3,3]);title('输出波形');grid on;

t=(0:100)/fs;

figure(4)

fs=1.5*10000;

n=(0:100)/fs;

f=sin(2*pi*400*t)+3*sin(2*pi*3000*t)+2*sin(2*pi*5000*t);

y=fftfilt(b,x);

[H1,f1]=freqz(f,[1]);

[H2,f2]=freqz(y,[1]);

f1=f1/pi*fs/2;

f2=f2/pi*fs/2;

subplot(2,1,1);plot(f1,abs(H1));title('输入信号的频谱');

subplot(2,1,2);plot(f2,abs(H2));title('输出信号的频谱');

00.10.2

0.30.40.50.60.70.80.91

-800

-600-400-200

Normalized Frequency (⨯π rad/sample)

P h a s e (d e g r e e s )

00.10.2

0.30.40.50.60.70.80.91

-100

-50

Normalized Frequency (⨯π rad/sample)

M a g n i t u d e (d B )

100020003000

40005000600070008000

00.20.40.60.8

1

1.2

1.4

频率/Hz

幅值

00.0010.0020.0030.0040.0050.0060.0070.0080.009

0.01

-50

5输入信号

020406080100120140160180200

-2

2输出序列

0.0010.0020.0030.0040.0050.0060.0070.0080.009

0.01

-20

2输出波形

010002000300040005000600070008000

50100150

200输入信号的频谱

010002000300040005000600070008000

10

20

30输出信号的频谱

N =

4

wc =

1.7947

b =

0.0186 -0.0410 0.1082 -0.1355 0.1810 -0.1355 0.1082 -0.0410 0.0186

a =

1.0000 -0.6707 -1.3750 0.5678 1.1964 -0.2996 -0.4631 0.0496 0.0762

>

相关文档
最新文档