数字信号处理实验六.docx
《数字信号处理实验六.docx》由会员分享,可在线阅读,更多相关《数字信号处理实验六.docx(11页珍藏版)》请在冰豆网上搜索。
![数字信号处理实验六.docx](https://file1.bdocx.com/fileroot1/2022-11/24/61da8bac-3848-4588-bcda-9728dc3af232/61da8bac-3848-4588-bcda-9728dc3af2321.gif)
数字信号处理实验六
实验六
Q7-1
clf;
Fp=4000;Fs=8000;
Wp=2*pi*Fp;Ws=2*pi*Fs;
[N1,Wn1]=buttord(Wp,Ws,0.5,40,'s');
[b1,a1]=butter(N,Wn,'s');
[N2Wn2]=cheb1ord(Wp,Ws,0.5,40,'s');
[b2,a2]=cheby1(N,0.5,Wn,'s')
[N3Wn3]=cheb2ord(Wp,Ws,0.5,40,'s');
[b3,a3]=cheby2(N,0.5,Wn,'s')
[N4Wn4]=ellipord(Wp,Ws,0.5,40,'s');
[b4,a4]=ellip(N,0.5,40,Wn,'s')
%[b,a]=cheby1(N,Wn,'s');
wa=0:
(3*Ws)/40000:
3*Ws;
h1=freqs(b1,a1,wa);
h2=freqs(b2,a2,wa);
h3=freqs(b3,a3,wa);
h4=freqs(b4,a4,wa);
subplot(2,2,1)
plot(wa/(2*pi),20*log10(abs(h1)));grid
xlabel('Frequency,Hz');ylabel('Gain,dB');
title('buttordGainresponse');
axis([03*Fs-605]);
subplot(2,2,2)
plot(wa/(2*pi),20*log10(abs(h2)));grid
xlabel('Frequency,Hz');ylabel('Gain,dB');
title('cheb1ordGainresponse');
axis([03*Fs-605]);
subplot(2,2,3)
plot(wa/(2*pi),20*log10(abs(h3)));grid
xlabel('Frequency,Hz');ylabel('Gain,dB');
title('cheb2ordGainresponse');
axis([03*Fs-605]);
subplot(2,2,4)
plot(wa/(2*pi),20*log10(abs(h4)));grid
xlabel('Frequency,Hz');ylabel('Gain,dB');
title('ellipordGainresponse');
axis([03*Fs-605]);
disp('N1的值')
disp(N1)
disp('N2的值')
disp(N2)
disp('N3的值')
disp(N3)
disp('N4的值')
disp(N4)
巴特沃兹:
9阶切比雪夫I,II:
5阶椭圆滤波器:
4阶
Q7-5
clf
Ws=[0.40.6];Wp=[0.20.8];Rp=0.4;Rs=50;
%EstimatetheFilterOrder
[N1,Wn1]=buttord(Wp,Ws,Rp,Rs);
%DesigntheFilter
[num,den]=butter(N1,Wn1,'stop');
%Displaythetransferfunction
disp('NumeratorCoefficientsare');disp(num);
disp('DenominatorCoefficientsare');disp(den);
%Computethegainresponse
[g,w]=gain(num,den);
%Plotthegainresponse
plot(w/pi,g);grid
axis([01-605]);
xlabel('\omega/\pi');ylabel('GainindB');
title('GainResponseofaButterworthBandstopFilter');
传输函数的表达式为:
,设计不符合指标,通带边界频率不符合要求。
Q7-6
clf
Ws=[0.4];Wp=[0.2];Rp=0.5;Rs=40;
[N1,Wn1]=cheb1ord(Wp,Ws,Rp,Rs);
[num,den]=cheby1(N1,0.5,Wn1);
disp('NumeratorCoefficientsare');disp(num);
disp('DenominatorCoefficientsare');disp(den);
[g,w]=gain(num,den);
plot(w/pi,g);grid
axis([01-605]);
xlabel('\omega/\pi');ylabel('GainindB');
title('GainResponseofaButterworthBandstopFilter');
传输函数的表达式为:
,设计符合指标。
Q7-13
clf
N=kaiord(2000,2500,0.005,0.005,10000)
disp(N)
计算所得阶数为46,ceil的作用是返回大于或等于指定表达式的最小整数。
nargin的作用是输入参数个数。
Q7-20
clf
b=fir1(200,0.4)
disp(b)
[g,w]=gain(b,1)
plot(w/pi,g)
Grid
阶数为46时:
当阶数为200时:
符合设计要求。
Q7-25
clf
fpts=[00.250.30.450.51]
mval=[0.40.4110.80.8]
b=fir2(95,fpts,mval)
w=0:
8*pi/511:
2*pi;
h=freqz(b,1,w);
plot(w/pi,abs(h));grid
%disp(b)
%[g,w]=gain(b,1)
%plot(w/pi,g)
%grid
Q8-1
Wp=[0.40.5];Ws=[0.10.8];Rp=1;Rs=30;
[N1,Wn1]=buttord(Wp,Ws,Rp,Rs);
[num,den]=butter(N1,Wn1);
disp('Numeratorcoefficientsare');disp(num);
disp('Denominatorcoefficientsare');disp(den);
impres=direct2(num,den,[1zeros(1,4*N1)]);
[p,d]=strucver(impres,2*N1);
disp('Actualnumeratorcoeffsare');disp(p');
disp('Actualdenominatorcoeffsare');disp(d');
disp(N1)
[g,w]=gain(num,den);
plot(w/pi,g);grid
Numeratorcoefficientsare
0.05710-0.114300.0571
Denominatorcoefficientsare
1.0000-0.50991.2862-0.33500.4479
Actualnumeratorcoeffsare
0.0571-0.0000-0.11430.00000.0571
Actualdenominatorcoeffsare
1.0000-0.50991.2862-0.33500.4479
Q8-2
Wp=[0.40.5];Ws=[0.10.8];Rp=1;Rs=30;
[N1,Wn1]=buttord(Wp,Ws,Rp,Rs);
[num,den]=butter(N1,Wn1);
disp('Numeratorcoefficientsare');disp(num);
disp('Denominatorcoefficientsare');disp(den);
impres=filter(num,den,[1zeros(1,4*N1)]);
[p,d]=strucver(impres,2*N1);
disp('Actualnumeratorcoeffsare');disp(p');
disp('Actualdenominatorcoeffsare');disp(d');
disp(N1)
[g,w]=gain(num,den);
plot(w/pi,g);grid
Numeratorcoefficientsare
0.05710-0.114300.0571
Denominatorcoefficientsare
1.0000-0.50991.2862-0.33500.4479
Actualnumeratorcoeffsare
0.0571-0.0000-0.11430.00000.0571
Actualdenominatorcoeffsare
1.0000-0.50991.2862-0.33500.4479
Q8-9
clf;
k=0:
50;
w2=0.7*pi;w1=0.2*pi;
x1=1.5*cos(w1*k);x2=2*cos(w2*k);
x=x1+x2;
[N,Wn]=ellipord(0.25,0.55,0.5,50);
[num,den]=ellip(N,0.5,50,Wn);
disp(N)
[g,w]=gain(num,den);
plot(w/pi,g);grid
通带边界为0.25,阻带边界为0.55,通带波纹为0.5,最小阻带衰减为50,正弦序列频率分别为0.7
和0.2
。
Q8-10
clf;
k=0:
50;
w2=0.7*pi;w1=0.2*pi;
x1=1.5*cos(w1*k);x2=2*cos(w2*k);
x=x1+x2;
[N,Wn]=ellipord(0.25,0.55,0.5,50);
[num,den]=ellip(N,0.5,50,Wn);
disp(N)
[g,w]=gain(num,den);
%Plotthegainresponse
plot(w/pi,g);grid
%y=filter(num,den,x);
%subplot(2,1,1);
%stem(k,x);grid;axis([050-44]);
%xlabel('Timeindexn');ylabel('Amplitude');
%title('InputSequence');
%subplot(2,1,2);
%stem(k,y);grid;axis([050-44]);
%xlabel('Timeindexn');ylabel('Amplitude');
%title('OutputSequence');
输入信号经过滤波器后产生正弦信号,由于滤波器存在输入延迟,所以初始部分不是正规的正弦信号。