1、数字信号处理实验六 实验六 Q7-1clf;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);N2 Wn2= cheb1ord(Wp, Ws, 0.5, 40,s);b2,a2=cheby1(N,0.5,Wn,s)N3 Wn3= cheb2ord(Wp, Ws, 0.5, 40,s);b3,a3=cheby2(N,0.5,Wn,s)N4 Wn4= ellipord(Wp, Ws, 0.5, 40,s);b4,a4=ellip(N
2、,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);gridxlabel(Frequency, Hz);ylabel(Gain, dB);title(buttord Gain response);axis(0 3*Fs -60 5);subplot(2,2,2)plot
3、(wa/(2*pi), 20*log10(abs(h2);gridxlabel(Frequency, Hz);ylabel(Gain, dB);title(cheb1ord Gain response);axis(0 3*Fs -60 5);subplot(2,2,3)plot(wa/(2*pi), 20*log10(abs(h3);gridxlabel(Frequency, Hz);ylabel(Gain, dB);title(cheb2ord Gain response);axis(0 3*Fs -60 5);subplot(2,2,4)plot(wa/(2*pi), 20*log10(a
4、bs(h4);gridxlabel(Frequency, Hz);ylabel(Gain, dB);title(ellipord Gain response);axis(0 3*Fs -60 5);disp(N1的值)disp(N1)disp(N2的值)disp(N2)disp(N3的值)disp(N3)disp(N4的值)disp(N4)巴特沃兹:9阶 切比雪夫I,II:5阶 椭圆滤波器:4阶Q7-5clfWs = 0.4 0.6; Wp = 0.2 0.8; Rp = 0.4; Rs = 50;% Estimate the Filter OrderN1, Wn1 = buttord(Wp,
5、 Ws, Rp, Rs); % Design the Filternum,den = butter(N1,Wn1,stop); % Display the transfer functiondisp(Numerator Coefficients are );disp(num);disp(Denominator Coefficients are );disp(den);% Compute the gain responseg, w = gain(num,den); % Plot the gain responseplot(w/pi,g);grid axis(0 1 -60 5);xlabel(o
6、mega /pi); ylabel(Gain in dB);title(Gain Response of a Butterworth Bandstop Filter);传输函数的表达式为:,设计不符合指标,通带边界频率不符合要求。Q7-6clfWs = 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(Numerator Coefficients are );disp(num);disp(Denominator Coefficients
7、are );disp(den);g, w = gain(num,den); plot(w/pi,g);grid axis(0 1 -60 5);xlabel(omega /pi); ylabel(Gain in dB);title(Gain Response of a Butterworth Bandstop Filter);传输函数的表达式为:,设计符合指标。Q7-13clfN=kaiord(2000,2500,0.005,0.005,10000)disp(N)计算所得阶数为46,ceil的作用是返回大于或等于指定表达式的最小整数。nargin的作用是输入参数个数。Q7-20clfb=fir
8、1(200,0.4)disp(b)g,w=gain(b,1)plot(w/pi,g)Grid阶数为46时:当阶数为200时:符合设计要求。Q7-25clffpts=0 0.25 0.3 0.45 0.5 1mval=0.4 0.4 1 1 0.8 0.8b=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)% gridQ8-1Wp = 0.4 0.5; Ws = 0.1 0.8; Rp = 1; Rs = 30;N1,
9、 Wn1 = buttord(Wp, Ws, Rp, Rs);num,den = butter(N1,Wn1);disp(Numerator coefficients are );disp(num);disp(Denominator coefficients are );disp(den);impres = direct2(num,den,1 zeros(1,4*N1);p,d = strucver(impres,2*N1);disp(Actual numerator coeffs are ); disp(p);disp(Actual denominator coeffs are ); dis
10、p(d);disp(N1)g, w = gain(num,den); plot(w/pi,g);grid Numerator coefficients are 0.0571 0 -0.1143 0 0.0571Denominator coefficients are 1.0000 -0.5099 1.2862 -0.3350 0.4479Actual numerator coeffs are 0.0571 -0.0000 -0.1143 0.0000 0.0571Actual denominator coeffs are 1.0000 -0.5099 1.2862 -0.3350 0.4479
11、Q8-2Wp = 0.4 0.5; Ws = 0.1 0.8; Rp = 1; Rs = 30;N1, Wn1 = buttord(Wp, Ws, Rp, Rs);num,den = butter(N1,Wn1);disp(Numerator coefficients are );disp(num);disp(Denominator coefficients are );disp(den);impres = filter(num,den,1 zeros(1,4*N1);p,d = strucver(impres,2*N1);disp(Actual numerator coeffs are );
12、 disp(p);disp(Actual denominator coeffs are ); disp(d);disp(N1)g, w = gain(num,den); plot(w/pi,g);grid Numerator coefficients are 0.0571 0 -0.1143 0 0.0571Denominator coefficients are 1.0000 -0.5099 1.2862 -0.3350 0.4479Actual numerator coeffs are 0.0571 -0.0000 -0.1143 0.0000 0.0571Actual denominat
13、or coeffs are 1.0000 -0.5099 1.2862 -0.3350 0.4479Q8-9clf;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,正弦序列频率分
14、别为0.7和0.2。Q8-10clf;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 the gain responseplot(w/pi,g);grid % y = filter(num,den,x);% subplot(2,1,1);% stem(k,x); grid; axis(0 50 -4 4);% xlabel(Time index n); ylabel(Amplitude);% title(Input Sequence);% subplot(2,1,2);% stem(k,y); grid; axis(0 50 -4 4);% xlabel(Time index n); ylabel(Amplitude);% title(Output Sequence);输入信号经过滤波器后产生正弦信号,由于滤波器存在输入延迟,所以初始部分不是正规的正弦信号。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1