数字信号处理教学课件:DSP上机题总结

上传人:大米 文档编号:568807436 上传时间:2024-07-27 格式:PPT 页数:24 大小:167KB
返回 下载 相关 举报
数字信号处理教学课件:DSP上机题总结_第1页
第1页 / 共24页
数字信号处理教学课件:DSP上机题总结_第2页
第2页 / 共24页
数字信号处理教学课件:DSP上机题总结_第3页
第3页 / 共24页
数字信号处理教学课件:DSP上机题总结_第4页
第4页 / 共24页
数字信号处理教学课件:DSP上机题总结_第5页
第5页 / 共24页
点击查看更多>>
资源描述

《数字信号处理教学课件:DSP上机题总结》由会员分享,可在线阅读,更多相关《数字信号处理教学课件:DSP上机题总结(24页珍藏版)》请在金锄头文库上搜索。

1、Writing a MATLAB program to compute 128-point DFT of the following sequence, you must firstly use DFT definition (directly computing DFT) to compute and use MATLAB function to test the result. Plot the two resultsin one figure.%using DFT definition computen=0:31;x=sin(pi*n/4);y1=zeros(1,128);for k=1

2、:128 y=0; for n=1:32 y=y+x(n)*exp(-j*2*pi*(k-1)*(n-1)/128); end y1(k)=y;endk=1:128;subplot(2,1,1)plot(k,y1)%using MATLAB functionn1=0:31;x2=sin(pi*n1/4);y2=fft(x2,128);subplot(2,1,2)plot(k,y2)Using the function fir1 and window of Kaiser, design a linear-phase FIR lowpass filter meeting the following

3、 specifications: passband edge frequency=2kHz, stopband edge frequency=2.5kHz, passband ripple p=0.005, stopband ripples=0.005, and sampling rate of 10kHz.Plot its gain and phase responses and check if it meets the specifications?%using fir1 design FIR lowpass filtern,wn,beta,typ=kaiserord(2000 2500

4、,1 0,0.005 0.005,10000);b=fir1(n,wn,kaiser(n+1,beta),noscale);h,omega=freqz(b,1,256);subplot(2,1,1)plot(omega/pi,20*log10(abs(h);xlabel(omega/pi); ylabel(Gain, dB);subplot(2,1,2)plot(omega/pi,angle(h);gridtitle(Phase Spectrum)xlabel(omega/pi); ylabel(Phase, radians).Design a Type 1 Chebyshev IIR low

5、pass filter meeting the specifications as below: sampling rate of 12kHz, passband edge frequency of 2.1kHz, stopband edge frequency of 2.7kHz, passband ripple of 0.6dB, and a minimum stopband attenuation of 45dB. Write down the exact expression for the transfer function generated. Does your design m

6、eet the specifications? Fp=2100;Fs=2700;Ft=12000;Rp=0.6;Rs=45;Wp=2*Fp/Ft;Ws=2*Fs/Ft;N,Wn=cheb1ord(Wp,Ws,Rp,Rs);B,A=cheby1(N,Rp,Wn)Using MATLAB determine the second-order factored form of the following z-transforms. And show their pole-zero plots. Then determine all possible ROCs of above z-transform

7、. num=4 15.6 6 2.4 -6.4;den=3 2.4 6.3 -11.4 6;sos,G=tf2sos(num,den)z,p,k=tf2zp(num,den)zplane(z,p);Write a MATLAB program to compute and display the rational z-transform from its zero,poles and gain constant. If the DTFT of the causal system exists, try to plot its magnitude and phase spectra. Using

8、 this program to determine the rational form of a z-transform whose zero are at 1= 1.2, 2= 2.3-j0.5, 3= -0.4+j0.2, 4= -0.4-j0.2,5= 2.3+j0.5; the ploes are at 1= 0.5, 2= -0.75+j0.2, 3= 0.6+j0.7, 4= 0.6-j0.7,5= -0.75-j0.2; and the gain constant k is 2.1. z=input(input the zeros=);p=input(input the plo

9、es=);g=input(input the gain constant=);num,den=zp2tf(z,p,g);w = 0:pi/(255):pi;h=freqz(num,den,w);subplot(2,1,1)plot(w/pi,abs(h);gridtitle(Magnitude Spectrum)xlabel(omega/pi); ylabel(Magnitude)subplot(2,1,2)plot(w/pi,angle(h);gridtitle(Phase Spectrum)xlabel(omega/pi); ylabel(Phase, radians)input the

10、zeros=1.2 2.3-i*0.5 -0.4+i*0.2 -0.4-i*0.2 2.3+i*0.5input the ploes=0.5 -0.75+i*0.2 0.6+i*0.7 0.6-i*0.7 -0.75-i*0.2input the gain constant=2.1Design an FIR hanning digital lowpass filter with the following specifications: passband edge frequency 0.3 ,stopband edge frequency 0.4 , stopband attenuation

11、 40 dB. Please plot frequency-magnititude response and check if your design fit the specification。 Wp=0.3*pi;Ws=0.4*pi;Rs=40;dw=abs(Wp-Ws);M=ceil(3.11*pi/dw);Wc=(Wp+Ws)/(2*pi);n=-M:1:M;h=Wc*sinc(Wc*n);Wn=hann(2*M+1);h1=h.*Wn;H,w=freqz(h1,1,512);plot(w/pi,20*log10(abs(H);%or using b=fir1(N,Wc,hann(N+

12、1);M=3.11*pi/dw;N=ceil(2*M+1);Wc=(Wp+Ws)/(2*pi);h1=fir1(N,Wc,hann(N+1);Given a signal when using a sampling frequency fT= 20KHz, plot the magnitude and phase spectrum of the sampled sequence(given length-64). syms t;x=sin(0.1*pi*t)+2*cos(0.3*pi*5*t)+3*sin(0.5*pi*t);ft=20000;n=1:64;y=subs(x,t,n/ft);s

13、ubplot(2,1,1)h,w=freqz(y,1);plot(w/pi,abs(h);title(Magnitude spectrum of the sampled samples)xlabel(omega/pi); ylabel(Magnitude)subplot(2,1,2)plot(w/pi,angle(h);title(Phase spectrum of the sampled samples)xlabel(omega/pi); ylabel(Phase)Using the function fir1 and window of Hamming, design a linear-p

14、hase FIR lowpass filter meeting the following specifications: passband edge frequency=2kHz, stopband edge frequency=2.3kHz, passband ripple p=0.002, stopband ripples=0.002 and sampling rate of 20kHz.Plot its gain and phase responses and check if it meets the specifications? Fp=2000;Fs=2300;b1=0.002;

15、b2=0.002;Ft=20000;Wp=2*pi*Fp/Ft;Ws=2*pi*Fs/Ft;Wc=(Wp+Ws)/(2*pi);m=3.22*pi/abs(Wp-Ws);N=ceil(2*m+1);h=fir1(N,Wc); %h = fir1(N,Wn,WIN)不加win则默认用Hamming windowH,w=freqz(h,1,512);plot(w/pi,20*log10(abs(H);Using MATLAB program to Determine all possible ROCs of the following z-Transforms, and describe the

16、type of their inverse z-Transforms(left-sided, right-sided, two-sided sequences) associated with each of the ROCs. num=8.1 6.93 -23.82 10.5;den=1 1.52 0.18 -0.1768;z,p,k=tf2zp(num,den);zplane(z,p);%对于LTI IIR滤波器传递函数收敛域 为|z|2.3452 right-sided(causal)sequencez = -2.3452 0.7896 0.7000p = -1.2681 -0.5200

17、 0.2681k = 8.1000 design an IIR butterworth digital lowpass filter with the following specifications: sampling rate of 7kHz, passband edge frequency of 1.05kHz, stopband edge frequency of 1.4kHz, passband ripple of 0.4dB, and a minimum stopband attenuation of 30dB. plot frequency-magnitude and check

18、 if your design fits the specification. Fp=1050;Fs=1400;Ft=7000;Rp=0.4;Rs=30;Wp=2*Fp/Ft;Ws=2*Fs/Ft;N,Wn = buttord(Wp, Ws, Rp, Rs);b,a = butter(N,Wn);h,omega = freqz(b,a,256);gain = 20*log10(abs(h);plot (omega/pi,gain);grid;xlabel(omega/pi); ylabel(Gain, dB);title(IIR Butterworth Filter);Write a MATL

19、AB program to compute the first L samples of the inverse of rational z-transforms where the value of L is provided by the user through the command input. Using this program to compute and plot the first 50 samples of the inverse of following G(z). Use the command stem for plotting the sequence gener

20、ated by the inverse transform.L=input(input the L=);r=10/4 -8/2;p=-1/4 -1/2;k=-2;B,A=residuez(r,p,k);h t=impz(B,A,L);stem(t,h);Try to give a program to evaluate the following DTFT in the range :Then run the Program and compute the real and imaginary parts of the DTFT, and the magnitude and phase spe

21、ctra. Is the DTFT a periodic function of w? If it is, what is the period?. Can you explain the jump in the phase spectrum? The jump can be removed using the MATLAB command unwrap. Evaluate the phase spectrum with the jump removed num = input(Numerator coefficients = );den = input(Denominator coeffic

22、ients = );% Compute the frequency responsew = 0:pi/(k-1):pi;h = freqz(num, den, w);% Plot the frequency responsesubplot(2,2,1)plot(w/pi,real(h);gridtitle(Real part)xlabel(omega/pi); ylabel(Amplitude)subplot(2,2,2)plot(w/pi,imag(h);gridtitle(Imaginary part)xlabel(omega/pi); ylabel(Amplitude)subplot(2

23、,2,3)plot(w/pi,abs(h);gridtitle(Magnitude Spectrum)xlabel(omega/pi); ylabel(Magnitude)subplot(2,2,4)plot(w/pi,angle(h);grid %unwrap(angle(h)title(Phase Spectrum)xlabel(omega/pi); ylabel(Phase, radians)design an elliptic IIR lowpass filter with the following specifications: sampling rate of 7kHz, pas

24、sband edge frequency of 1.05kHz, stopband edge frequency of 1.4kHz, passband ripple of 0.4dB, and a minimum stopband attenuation of 30dB. plot frequency-magnitude and check if your design fits the specification Ft=7000;Fp=1050;Fs=1400;Rp=0.4;Rs=30;Wp=2*Fp/Ft;Ws=2*Fs/Ft;N, Wn = ELLIPORD(Wp, Ws, Rp, R

25、s);B,A = ELLIP(N,Rp,Rs,Wn);h,w=freqz(B,A,256);gain=20*log10(abs(h);plot(w/pi,gain);xlabel(omega/pi); ylabel(Gain, dB);title(Ellipitc IIR lowpass filter);Design using the windowed Fourier series approach a linear-phase FIR lowpass filter with the following specifications: passband edge at 3.1rad/sec,

26、 stopband edge at 5 rad/sec, maximum passband attenuation of 0.2dB, minimum stopband attenuation of 45dB, and a sampling frequency of 40rad/sec. Use the window of Hanning to perform it , then show the impulse response coefficients and plot the gain response of the designed filters. Wp=3.1*2*pi/40;Ws

27、=5*2*pi/40; Rp=0.2;Rs=45;dw=abs(Wp-Ws);M=ceil(3.11*pi/dw);Wc=(Wp+Ws)/(2*pi);n=-M:1:M;h=Wc*sinc(Wc*n);Wn=hann(2*M+1);N=2*M+1;b=fir1(N,Wc,hann(N+1);h1=h.*Wn;H,w=freqz(b,1,512);plot(w/pi,20*log10(abs(H);Generate and plot a sequence , with . Compute the energy of the sequence. n=0:50;x=sin(5*pi*n/16);st

28、em(n,x); %或者如下syms n1; %x1=xx1=sin(5*pi*n1/16).2; %y=x*x1y=symsum(x1,n1,0,50);y1=double(y)y1 = 25.5449Using MATLAB to determine the lowest order of a digital IIR lowpass filter of all four types(Butterworth, Type1 Cheby, Type2 Cheby, elliptic). The specifications are as following: sampling rate of 1

29、2kHz, passband edge frequency of 2.1kHz, stopband edge frequency of 2.7kHz, passband ripple of 0.6dB, and a minimum stopband attenuation of 45dB. Comment on your results.Ft=12000;Fp=2100;Fs=2700;Rp=0.6;Rs=45;Wp=2*Fp/Ft;Ws=2*Fs/Ft;N1=buttord(Wp,Ws,Rp,Rs);disp(butterworth);N1N2=cheb1ord(Wp,Ws,Rp,Rs);d

30、isp(Type1 cheby);N2N3=cheb2ord(Wp,Ws,Rp,Rs);disp(Type2 cheby);N3N4=ellipord(Wp,Ws,Rp,Rs);disp(elliptic);N4Butterworth:19Type1 cheby:8Type2 cheby:8Elliptic :5Consider the following periodic signal as below, which is sampled to get 512-points discrete-time signal The sampling period is second. Determi

31、ne the sampling type of the process. Sketch the time domain and frequency domain plot of continuous time and sampled signal. Analysis the sampling process. t=0:0.01:1;x=square(2*pi*t/0.4);subplot(2,2,1)plot(t,x,r);axis(0 1 0 2);%原始波形n=0:511;T=0.02;y=square(2*pi*n*T/0.4);hold onstem(n/50,y);axis(0 1

32、0 2);%采样后波形 hold offtitle(原始及采样信号时域波形);h1,w1=freqz(x,1);h=fft(y,256);subplot(2,2,2)plot(w1/pi,abs(h1),r);%原始信号频域波形title(原始信号频域波形);axis(0 1 0 max(abs(h1);subplot(2,2,3)n=0:255;plot(n,abs(h);%采样后频域波形title(采样后频域波形);Writing a MATLAB program to compute the linear convolution of two length-N sequences. Us

33、ing this program to determine the following pair of sequences: And plot the result sequence.n=0:10;g=cos(0.2*pi*n);h=3.n;y=conv(g,h);n1=0:length(y)-1;stem(n1,y);Writing a MATLAB program to compute the circular convolution of two length-N sequences via the DFT-based approach. Using this program to de

34、termine the following pair of sequences:gn=7, 4, -9, 0, 2, -5, hn=1, -1, 2, 0, 10, 5 or And plot the result sequence.x1=7 4 -9 0 2 -5;x2=1 -1 2 0 10 5;L=length(x1);y=zeros(1,L);x2tr = x2(1) x2(L:-1:2);for k = 1:L, sh = circshift(x2tr, k-1); h = x1.*sh; y(k) = sum(h);enddisp(y);n=0:length(x1)-1;stem(

35、n,y);%n=0:15;%x1=exp(j*pi*n/4);%x2=2.n;Consider the following signal , which is sampled to get discrete-time signal The sampling period is second. Determine the sampling type of the process. Sketch the time domain and frequency domain plot of continuous time and sampled signal. Analysis the sampling

36、 process. t=0:0.01:10;x=sin(pi*t/4);subplot(2,2,1)plot(t,x,r);axis(0 10 -1.5 1.5);%原始信号时域波形n=0:128;T=0.5;y=sin(pi*n*T/4);hold onstem(n/2,y);axis(0 10 -1.5 1.5);%采样后时域波形 hold offtitle(原始及采样后时域波形);h1,w1=freqz(x,1);h=fft(y,256);subplot(2,2,2)plot(w1/pi,abs(h1),r);%原始信号频域波形title(原始信号频域波形);axis(-0.5 0.5

37、0 max(abs(h1);subplot(2,2,3)n=0:255;plot(n,abs(h);%采样后频域波形title(采样后频域波形);Write a MATLAB program to determine the partial-fraction expansion of the z-transform listed the following G(z) and then determine their inverse z-transforms. num=2 5 9 5 3;den=5 45 2 1 1;r,p,k=residuez(num,den);r1=r(2) r(3);p1

38、=p(2) p(3);b,a=residuez(r1,p1,0);h=impz(num,den); %参考书P444Write a MATLAB program to compute and plot the frequency response of a causal LTI discrete-time system with a transfer function given by for 0.What type of filter does it represent(lowpass, highpass, bandpass, bandstop or allpass)?num=0.15 0

39、-0.15;den=1 -0.5 0.7;h,w=freqz(num,den);plot(w/pi,abs(h);%从图看似乎是bandpassWrite a MATLAB program to compute and plot the response of input as and a causal finite-dimensional discrete-time system characterized by a difference equation of the following form: Generate and plot the first 31 samples of the

40、 sinusoidal response of the system.num=1.8 0.34 -1.32 -0.86;den=1 0.3 0.5 -0.72;n=0:30;x=cos(0.2*pi*n);y=filter(num,den,x);subplot(2,1,1)stem(n,y);title(输出信号);subplot(2,1,2)h,T=impz(num,den,31);stem(T,h);title(系统响应);Write a MATLAB program to compute and plot the response of input as and a causal fin

41、ite-dimensional discrete-time system characterized by a difference equation of the following form: Generate and plot the first 41 samples of the the response of the system.num=0.8 -0.44 0.36 0.02;den=1 0.7 -0.45 -0.6;n=0:15;x=ones(1,16);y=filter(num,den,x);subplot(2,1,1)stem(n,y);title(输出信号);subplot(2,1,2)h,T=impz(num,den,41);stem(T,h);title(系统响应);

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 研究生课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号