第四次数字信号处理实验.docx
《第四次数字信号处理实验.docx》由会员分享,可在线阅读,更多相关《第四次数字信号处理实验.docx(13页珍藏版)》请在冰豆网上搜索。
![第四次数字信号处理实验.docx](https://file1.bdocx.com/fileroot1/2023-2/8/a079c8be-b2f0-4be8-ba8f-3a9f41acf659/a079c8be-b2f0-4be8-ba8f-3a9f41acf6591.gif)
第四次数字信号处理实验
第六章:
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)%求数字系统函数
[H,W]=freqz(num2,den2);
plot(W*Fs/2/pi,abs(H));grid;
xlabel('频率/Hz');
ylabel('幅值');
Warning:
Theoutputisnotcorrect/robust.
CoeffsofB(s)/A(s)arereal,butB(z)/A(z)hascomplexcoeffs.
Probablecauseisrootingofhigh-orderrepeatedpolesinA(s).
>Inimpinvarat122
num2=
Columns1through10
0.00010.00040.00060.00530.14491.07033.20764.87954.21312.1869
Columns11through20
0.70090.13950.01710.00120.00010.00000.00000.00000.00000.0000
Columns21through22
0.00000
den2=
Columns1through10
1.00003.30444.86504.13002.23200.80190.19580.03250.00370.0003
Columns11through20
0.0000-0.00000.0000-0.00000.0000-0.00000.0000-0.00000.0000-0.0000
Columns21through22
0.0000-0.0000
2:
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('频率/Hz');
ylabel('幅值');
N=
4
wc=
0.2613
B=
0.01180.04730.07090.04730.0118
A=
1.0000-1.87781.6214-0.66300.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);
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)));
gridon;
subplot(2,2,2);
plot(RAD,20*log10(abs(MAG2)));
gridon;
subplot(2,2,3);
plot(RAD,20*log10(abs(MAG3)));
gridon;
subplot(2,2,4);
plot(RAD,20*log10(abs(MAG4)));
gridon;
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)');
gridon;
k=1:
M/2+1;
w=2*(0:
M/2)/M
subplot(2,1,2);
plot(w,20*log10(abs(Hk(k))));
axis([0,1,-100,5]);
xlabel('w/pi');ylabel('20lg∣H(w)∣');
gridon;
w=
Columns1through10
00.00200.00390.00590.00780.00980.01170.01370.01560.0176
Columns11through20
0.01950.02150.02340.02540.02730.02930.03130.03320.03520.0371
Columns21through30
0.03910.04100.04300.04490.04690.04880.05080.05270.05470.0566
Columns31through40
0.05860.06050.06250.06450.06640.06840.07030.07230.07420.0762
Columns41through50
0.07810.08010.08200.08400.08590.08790.08980.09180.09380.0957
Columns51through60
0.09770.09960.10160.10350.10550.10740.10940.11130.11330.1152
Columns61through70
0.11720.11910.12110.12300.12500.12700.12890.13090.13280.1348
Columns71through80
0.13670.13870.14060.14260.14450.14650.14840.15040.15230.1543
Columns81through90
0.15630.15820.16020.16210.16410.16600.16800.16990.17190.1738
Columns91through100
0.17580.17770.17970.18160.18360.18550.18750.18950.19140.1934
Columns101through110
0.19530.19730.19920.20120.20310.20510.20700.20900.21090.2129
Columns111through120
0.21480.21680.21880.22070.22270.22460.22660.22850.23050.2324
Columns121through130
0.23440.23630.23830.24020.24220.24410.24610.24800.25000.2520
Columns131through140
0.25390.25590.25780.25980.26170.26370.26560.26760.26950.2715
Columns141through150
0.27340.27540.27730.27930.28130.28320.28520.28710.28910.2910
Columns151through160
0.29300.29490.29690.29880.30080.30270.30470.30660.30860.3105
Columns161through170
0.31250.31450.31640.31840.32030.32230.32420.32620.32810.3301
Columns171through180
0.33200.33400.33590.33790.33980.34180.34380.34570.34770.3496
Columns181through190
0.35160.35350.35550.35740.35940.36130.36330.36520.36720.3691
Columns191through200
0.37110.37300.37500.37700.37890.38090.38280.38480.38670.3887
Columns201through210
0.39060.39260.39450.39650.39840.40040.40230.40430.40630.4082
Columns211through220
0.41020.41210.41410.41600.41800.41990.42190.42380.42580.4277
Columns221through230
0.42970.43160.43360.43550.43750.43950.44140.44340.44530.4473
Columns231through240
0.44920.45120.45310.45510.45700.45900.46090.46290.46480.4668
Columns241through250
0.46880.47070.47270.47460.47660.47850.48050.48240.48440.4863
Columns251through260
0.48830.49020.49220.49410.49610.49800.50000.50200.50390.5059
Columns261through270
0.50780.50980.51170.51370.51560.51760.51950.52150.52340.5254
Columns271through280
0.52730.52930.53130.53320.53520.53710.53910.54100.54300.5449
Columns281through290
0.54690.54880.55080.55270.55470.55660.55860.56050.56250.5645
Columns291through300
0.56640.56840.57030.57230.57420.57620.57810.58010.58200.5840
Columns301through310
0.58590.58790.58980.59180.59380.59570.59770.59960.60160.6035
Columns311through320
0.60550.60740.60940.61130.61330.61520.61720.61910.62110.6230
Columns321through330
0.62500.62700.62890.63090.63280.63480.63670.63870.64060.6426
Columns331through340
0.64450.64650.64840.65040.65230.65430.65630.65820.66020.6621
Columns341through350
0.66410.66600.66800.66990.67190.67380.67580.67770.67970.6816
Columns351through360
0.68360.68550.68750.68950.69140.69340.69530.69730.69920.7012
Columns361through370
0.70310.70510.70700.70900.71090.71290.71480.71680.71880.7207
Columns371through380
0.72270.72460.72660.72850.73050.73240.73440.73630.73830.7402
Columns381through390
0.74220.74410.74610.74800.75000.75200.75390.75590.75780.7598
Columns391through400
0.76170.76370.76560.76760.76950.77150.77340.77540.77730.7793
Columns401through410
0.78130.78320.78520.78710.78910.79100.79300.79490.79690.7988
Columns411through420
0.80080.80270.80470.80660.80860.81050.81250.81450.81640.8184
Columns421through430
0.82030.82230.82420.82620.82810.83010.83200.83400.83590.8379
Columns431through440
0.83980.84180.84380.84570.84770.84960.85160.85350.85550.8574
Columns441through450
0.85940.86130.86330.86520.86720.86910.87110.87300.87500.8770
Columns451through460
0.87890.88090.88280.88480.88670.88870.89060.89260.89450.8965
Columns461through470
0.89840.90040.90230.90430.90630.90820.91020.91210.91410.9160
Columns471through480
0.91800.91990.92190.92380.92580.92770.92970.93160.93360.9355
Columns481through490
0.93750.93950.94140.94340.94530.94730.94920.95120.95310.9551
Columns491through500
0.95700.95900.96090.96290.96480.96680.96880.97070.97270.9746
Columns501through510
0.97660.97850.98050.98240.98440.98630.98830.99020.99220.9941
Columns511through513
0.99610.99801.0000
3:
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([0pi-1000]);