1、第四次数字信号处理实验第六章:1:Wp=2*pi*400;Ws=2*pi*600;ap=0.3; as=60;Fs=1000; N,Wc=buttord(Wp,Ws,ap,as,s); %求阶数N和3dB截止频率Wc Z,P,K=buttap(N); A,B,C,D=zp2ss(Z,P,K);%将模拟滤波器的零、极点形式转换为状态空间形式 At,Bt,Ct,Dt=lp2lp(A,B,C,D,Wc);%去归一化 num1,den1=ss2tf(At,Bt,Ct,Dt);%由状态空间形式转换为模拟系统函数的系数 num2,den2 =impinvar(num1,den1,Fs) %求数字系统函数
2、H,W=freqz(num2,den2);plot(W*Fs/2/pi,abs(H);grid;xlabel(频率/Hz);ylabel(幅值);Warning: The output is not correct/robust.Coeffs of B(s)/A(s) are real, but B(z)/A(z) has complex coeffs. Probable cause is rooting of high-order repeated poles in A(s). In impinvar at 122num2 = Columns 1 through 10 0.0001 0.00
3、04 0.0006 0.0053 0.1449 1.0703 3.2076 4.8795 4.2131 2.1869 Columns 11 through 20 0.7009 0.1395 0.0171 0.0012 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 Columns 21 through 22 0.0000 0den2 = Columns 1 through 10 1.0000 3.3044 4.8650 4.1300 2.2320 0.8019 0.1958 0.0325 0.0037 0.0003 Columns 11 through 20
4、 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 Columns 21 through 22 0.0000 -0.00002:wp=0.2;ws=0.6;ap=3; as=40;%注意wp,ws是关于的归一化的值 N,wc=buttord(wp,ws,ap,as) %求数字滤波器阶数N和3dB截止频率wc B,A=butter(N,wc) %调用butter计算数字滤波器系统函数系数向量B和A H,lW=freqz(B,A);plot(W*Fs/2/pi,abs(H);grid;xlabel(
5、频率/Hz);ylabel(幅值);N = 4wc = 0.2613B = 0.0118 0.0473 0.0709 0.0473 0.0118A =1.0000 -1.8778 1.6214 -0.6630 0.1087第七章1:passrad=2*pi*100/1000; w1=boxcar(81); %矩形窗 w2=triang(81); %三角窗 w3=hanning(81); %汉宁窗w4=hamming(81); %矩形窗 n=1:1:81;hd=sin(passrad*(n-41)./(pi*(n-41);hd(41)= passrad/pi; h1=hd.*rot90(w1);
6、 h2=hd.*rot90(w2); h3=hd.*rot90(w3); h4=hd.*rot90(w4); MAG1,RAD=freqz(h1); MAG2,RAD=freqz(h2); MAG3,RAD=freqz(h3); MAG4,RAD=freqz(h4);subplot(2,2,1);plot(RAD,20*log10(abs(MAG1);grid on;subplot(2,2,2);plot(RAD,20*log10(abs(MAG2);grid on;subplot(2,2,3);plot(RAD,20*log10(abs(MAG3);grid on;subplot(2,2,4
7、);plot(RAD,20*log10(abs(MAG4);grid on;2:fp=2000;fs=3000;Fs=10000;wp=2*pi*fp/Fs; ws=2*pi*fs/Fs;B=ws-wp;N=ceil(8*pi/B);wc=(wp+B/2) /pi;hn=fir1(N-1,wc); M=1024;Hk=fft(hn,M);n=0:N-1;subplot(2,1,1);stem(n,hn,.);xlabel(n);ylabel(h(n);grid on; k=1:M/2+1; w=2*(0:M/2)/Msubplot(2,1,2);plot(w,20*log10(abs(Hk(k
8、);axis(0,1,-100,5);xlabel(w/pi);ylabel(20lgH(w);grid on;w = Columns 1 through 10 0 0.0020 0.0039 0.0059 0.0078 0.0098 0.0117 0.0137 0.0156 0.0176 Columns 11 through 20 0.0195 0.0215 0.0234 0.0254 0.0273 0.0293 0.0313 0.0332 0.0352 0.0371 Columns 21 through 30 0.0391 0.0410 0.0430 0.0449 0.0469 0.048
9、8 0.0508 0.0527 0.0547 0.0566 Columns 31 through 40 0.0586 0.0605 0.0625 0.0645 0.0664 0.0684 0.0703 0.0723 0.0742 0.0762 Columns 41 through 50 0.0781 0.0801 0.0820 0.0840 0.0859 0.0879 0.0898 0.0918 0.0938 0.0957 Columns 51 through 60 0.0977 0.0996 0.1016 0.1035 0.1055 0.1074 0.1094 0.1113 0.1133 0
10、.1152 Columns 61 through 70 0.1172 0.1191 0.1211 0.1230 0.1250 0.1270 0.1289 0.1309 0.1328 0.1348 Columns 71 through 80 0.1367 0.1387 0.1406 0.1426 0.1445 0.1465 0.1484 0.1504 0.1523 0.1543 Columns 81 through 90 0.1563 0.1582 0.1602 0.1621 0.1641 0.1660 0.1680 0.1699 0.1719 0.1738 Columns 91 through
11、 100 0.1758 0.1777 0.1797 0.1816 0.1836 0.1855 0.1875 0.1895 0.1914 0.1934 Columns 101 through 110 0.1953 0.1973 0.1992 0.2012 0.2031 0.2051 0.2070 0.2090 0.2109 0.2129 Columns 111 through 120 0.2148 0.2168 0.2188 0.2207 0.2227 0.2246 0.2266 0.2285 0.2305 0.2324 Columns 121 through 130 0.2344 0.2363
12、 0.2383 0.2402 0.2422 0.2441 0.2461 0.2480 0.2500 0.2520 Columns 131 through 140 0.2539 0.2559 0.2578 0.2598 0.2617 0.2637 0.2656 0.2676 0.2695 0.2715 Columns 141 through 150 0.2734 0.2754 0.2773 0.2793 0.2813 0.2832 0.2852 0.2871 0.2891 0.2910 Columns 151 through 160 0.2930 0.2949 0.2969 0.2988 0.3
13、008 0.3027 0.3047 0.3066 0.3086 0.3105 Columns 161 through 170 0.3125 0.3145 0.3164 0.3184 0.3203 0.3223 0.3242 0.3262 0.3281 0.3301 Columns 171 through 180 0.3320 0.3340 0.3359 0.3379 0.3398 0.3418 0.3438 0.3457 0.3477 0.3496 Columns 181 through 190 0.3516 0.3535 0.3555 0.3574 0.3594 0.3613 0.3633
14、0.3652 0.3672 0.3691 Columns 191 through 200 0.3711 0.3730 0.3750 0.3770 0.3789 0.3809 0.3828 0.3848 0.3867 0.3887 Columns 201 through 210 0.3906 0.3926 0.3945 0.3965 0.3984 0.4004 0.4023 0.4043 0.4063 0.4082 Columns 211 through 220 0.4102 0.4121 0.4141 0.4160 0.4180 0.4199 0.4219 0.4238 0.4258 0.42
15、77 Columns 221 through 230 0.4297 0.4316 0.4336 0.4355 0.4375 0.4395 0.4414 0.4434 0.4453 0.4473 Columns 231 through 240 0.4492 0.4512 0.4531 0.4551 0.4570 0.4590 0.4609 0.4629 0.4648 0.4668 Columns 241 through 250 0.4688 0.4707 0.4727 0.4746 0.4766 0.4785 0.4805 0.4824 0.4844 0.4863 Columns 251 thr
16、ough 260 0.4883 0.4902 0.4922 0.4941 0.4961 0.4980 0.5000 0.5020 0.5039 0.5059 Columns 261 through 270 0.5078 0.5098 0.5117 0.5137 0.5156 0.5176 0.5195 0.5215 0.5234 0.5254 Columns 271 through 280 0.5273 0.5293 0.5313 0.5332 0.5352 0.5371 0.5391 0.5410 0.5430 0.5449 Columns 281 through 290 0.5469 0.
17、5488 0.5508 0.5527 0.5547 0.5566 0.5586 0.5605 0.5625 0.5645 Columns 291 through 300 0.5664 0.5684 0.5703 0.5723 0.5742 0.5762 0.5781 0.5801 0.5820 0.5840 Columns 301 through 310 0.5859 0.5879 0.5898 0.5918 0.5938 0.5957 0.5977 0.5996 0.6016 0.6035 Columns 311 through 320 0.6055 0.6074 0.6094 0.6113
18、 0.6133 0.6152 0.6172 0.6191 0.6211 0.6230 Columns 321 through 330 0.6250 0.6270 0.6289 0.6309 0.6328 0.6348 0.6367 0.6387 0.6406 0.6426 Columns 331 through 340 0.6445 0.6465 0.6484 0.6504 0.6523 0.6543 0.6563 0.6582 0.6602 0.6621 Columns 341 through 350 0.6641 0.6660 0.6680 0.6699 0.6719 0.6738 0.6
19、758 0.6777 0.6797 0.6816 Columns 351 through 360 0.6836 0.6855 0.6875 0.6895 0.6914 0.6934 0.6953 0.6973 0.6992 0.7012 Columns 361 through 370 0.7031 0.7051 0.7070 0.7090 0.7109 0.7129 0.7148 0.7168 0.7188 0.7207 Columns 371 through 380 0.7227 0.7246 0.7266 0.7285 0.7305 0.7324 0.7344 0.7363 0.7383
20、0.7402 Columns 381 through 390 0.7422 0.7441 0.7461 0.7480 0.7500 0.7520 0.7539 0.7559 0.7578 0.7598 Columns 391 through 400 0.7617 0.7637 0.7656 0.7676 0.7695 0.7715 0.7734 0.7754 0.7773 0.7793 Columns 401 through 410 0.7813 0.7832 0.7852 0.7871 0.7891 0.7910 0.7930 0.7949 0.7969 0.7988 Columns 411
21、 through 420 0.8008 0.8027 0.8047 0.8066 0.8086 0.8105 0.8125 0.8145 0.8164 0.8184 Columns 421 through 430 0.8203 0.8223 0.8242 0.8262 0.8281 0.8301 0.8320 0.8340 0.8359 0.8379 Columns 431 through 440 0.8398 0.8418 0.8438 0.8457 0.8477 0.8496 0.8516 0.8535 0.8555 0.8574 Columns 441 through 450 0.859
22、4 0.8613 0.8633 0.8652 0.8672 0.8691 0.8711 0.8730 0.8750 0.8770 Columns 451 through 460 0.8789 0.8809 0.8828 0.8848 0.8867 0.8887 0.8906 0.8926 0.8945 0.8965 Columns 461 through 470 0.8984 0.9004 0.9023 0.9043 0.9063 0.9082 0.9102 0.9121 0.9141 0.9160 Columns 471 through 480 0.9180 0.9199 0.9219 0.
23、9238 0.9258 0.9277 0.9297 0.9316 0.9336 0.9355 Columns 481 through 490 0.9375 0.9395 0.9414 0.9434 0.9453 0.9473 0.9492 0.9512 0.9531 0.9551 Columns 491 through 500 0.9570 0.9590 0.9609 0.9629 0.9648 0.9668 0.9688 0.9707 0.9727 0.9746 Columns 501 through 510 0.9766 0.9785 0.9805 0.9824 0.9844 0.9863 0.9883 0.9902 0.9922 0.9941 Columns 511 through 513 0.9961 0.9980 1.00003:delta=0.4*pi; wc=0.2*pi; as=40; n=ceil(8*pi/delta)+1; win=hamming(n);%哈明窗h=fir1(n-1,wc/pi,win);omega=linspace(0,pi,512);mag=freqz(h,1,omega); magdb=20*log10(abs(mag); plot(omega,magdb);axis(0 pi -100 0);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1