您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 其它文档 > MATLAB机考样题(带答案)
MATLAB机考样题:(1)Generateandplotsequence121[]2cos()[][4]8xnnandxnxn,with20n20.n1=-20:20;x1=2*cos(pi/8*n1);n2=n1-4;x2=2*cos(pi/8*n2);subplot(2,1,1);plot(n1,x1);subplot(212);plot(n2,x2);(2)WriteaMATLABprogramtocomputeandplottheimpulseresponseofacausalfinite-dimensionaldiscrete-timesystemcharacterizedbyadifferenceequationofthefollowingform:3]-x[n86.02]-1.32x[n1]-0.34x[nx[n]8.13]-0.72y[n-2]-0.5y[n1]-0.3y[ny[n]N=input('请输入你要求的点数N=');num=[1.80.34-1.32-0.86];den=[10.30.5-0.72];x=[1zeros(1,N-1)];(单位冲击)y=filter(num,den,x);plot(0:N-1,y);(3)WriteaMATLABprogramtocomputeanddisplaythepolesandzeros,tocomputeanddisplaythesecond-orderfactoredform,andtogeneratethepole-zeroplotofaz-transformthatisaratiooftwopolynomialsinz-1.UsingthisprogramtoanalyzethefollowingG(z):3213211768.018.052.115.1082.2393.61.8)(zzzzzzzHnum=[8.16.93-23.8210.5];den=[11.520.18-0.1768];sos=tf2sos(num,den)%tf2sos表示为1/z的升幂zplane(num,den)(4)TrytogiveaprogramtoevaluatethefollowingDTFTintherange0:4324321245535952)(jjjjjjjjeeeeeeeezG%由于用freqz计算频点至少是2个,所以至少输入两个频点w1=input('请输入你要计算的频点w1=');w2=input('请输入你要计算的频点w2=');w=[w1w2];num=[25953];den=[545211];h=freqz(num,den,w)(6)WriteaMATLABprogramtocomputeandplotthemagnituderesponseofacausalLTIdiscrete-timesystemwithatransferfunctiongivenby2127.05.01)1(15.0)(zzzzHnum=0.15*[10-1];den=[1-0.50.7];[h,w]=freqz(num,den,512);plot(w/pi,abs(h));(7)ConsiderthefollowingFIRtransferfunction:123456()10.60.490.480.140.120.09HzzzzzzzUsingMATLABtodetermineitszerolocationsandplotitsmagnitudeandphaseresponse.h=[10.6.49-0.48-0.14-0.120.09];figure(1)zplane(h,1);[H,w]=freqz(h,1,512);figure(2)plot(w/pi,abs(H));figure(3)plot(w/pi,angle(H));(8)Givenasignal()4cos0.1xttt,whenusingasamplingfrequencyfT=20KHz,plotthemagnitudeandphasespectrumofthesampledsequence(givenlength-64).fs=2e4;n=0:63;x=4*n/fs+cos(0.1*pi*n/fs);h=fft(x,1024);figure(1);plot(0:2/1023:2,abs(h));figure(2);plot(0:2/1023:2,angle(h));(9)designanIIRbutterworthdigitallowpassfilterwiththefollowingspecifications:samplingrateof40kHz,passbandedgefrequencyof4kHz,stopbandedgefrequencyof8kHz,passbandrippleof0.5dB,andaminimumstopbandattenuationof40dB,plotfrequency-magnitudeandcheckifyourdesignfitsthespecification.fs=40;wp=4*2/fs;%wp1,没有乘piws=8*2/fs;%ws1,没有乘piap=0.5;as=40;[n,wn]=buttord(wp,ws,ap,as);[num,den]=butter(n,wn);[h,w]=freqz(num,den,512);figure(1);plot(w/pi,20*log10(abs(h)));axis([01-500]);figure(2);subplot(2,1,1);plot(w/pi,20*log10(abs(h)))axis([0wp-0.50]);title('通带纹波');subplot(2,1,2);plot(w/pi,20*log10(abs(h)));axis([ws1-50-30]);title('阻带纹波');(10)DesignaHanningFIRlowpassfiltermeetingthefollowingspecifications:passbandedgefrequency=2kHz,stopbandedgefrequency=2.5kHz,passbandrippleδp=0.005,stopbandrippleδs=0.005,andsamplingrateof10kHz.Plotitsgainandphaseresponsesandcheckifitmeetsthespecifications?ft=10;fp=2;fs=2.5;wp=2*pi*fp/ft;ws=2*pi*fs/ft;ds=0.005;ap=20*log10(1-ds)as=20*log10(ds)wc=(wp+ws)/2;dw=ws-wp;M=ceil(3.11*pi/dw);N=2*M;b=fir1(N,wc/pi,hann(N+1));[h,w]=freqz(b,1,512);figure(1);plot(w/pi,20*log10(abs(h)));axis([01-500]);title('magituderesponse');figure(2);plot(w/pi,unwrap(angle(h)));title('phaseresponse');figure(3);subplot(211);plot(w/pi,20*log10(abs(h)));axis([0wp/piap0]);title('通带纹波')subplot(212);plot(w/pi,20*log10(abs(h)));axis([ws/pi1as0]);title('阻带纹波');%从图中可以看出,通带和阻带中纹波都不满足要求,所以不满足指标%as=-46.020643.9所以不能用hanning窗设计%应当用hamming或blackman窗设计(11)WritingaMATLABprogramtocompute128-pointDFTofthefollowingsequence,youmustfirstlyuseDFTdefinition(directlycomputingDFT)tocomputeanduseMATLABfunctiontotesttheresult.Plotthetworesultsinonefigure.n=0:31;k=1:128;x=sin(pi*n/4);Xk1=zeros(1,128);fort=1:128form=1:32Xk1(t)=Xk1(t)+x(m)*exp(-1i*2*pi*(t-1).*(m-1)/128);endendsubplot(2,1,1);plot(k,Xk1);Xk2=fft(x,128);subplot(2,1,2);plot(k,Xk2);(12)Usingthefunctionfir1andwindowofKaiser,designalinear-phaseFIRlowpassfiltermeetingthefollowingspecifications:passbandedgefrequency=2kHz,stopbandedgefrequency=2.5kHz,passbandrippleδp=0.005,stopbandrippleδs=0.005,andsamplingrateof10kHz.Plotitsgainandphaseresponsesandcheckifitmeetsthespecifications?DesignaType1ChebyshevIIRlowpassfiltermeetingthespecificationsasbelow:samplingrateof12kHz,passbandedgefrequencyof2.1kHz,stopbandedgefrequencyof2.7kHz,passband[]sin(4),031gnnnrippleof0.6dB,andaminimumstopbandattenuationof45dB.Writedowntheexactexpressionforthetransferfunctiongenerated.Doesyourdesignmeetthespecifications?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)[h,w]=freqz(B,A,512);figure(1);plot(w/pi,20*log10(abs(h)));axis([01-500]);figure(2);subplot(2,1,1);plot(w/pi,20*log10(abs(h)))axis([0Wp-0.60]);title('通带纹波');subplot(2,1,2);plot(w/pi,20*log10(abs(h)));axis([Ws1-50-30]);title('阻带纹波');(13)Usingthefunctionfir1andwindowofKaiser,designalinear-phaseFIRlowpassfiltermeetingthefollowingspecifications:passbandedgefrequency=2kHz,stopbandedgefrequency=2.5kHz,passbandrippleδp=0.005,stopbandrippleδs=0.005,andsamplingrateof10kHz.Plotitsgainan
本文标题:MATLAB机考样题(带答案)
链接地址:https://www.777doc.com/doc-2882172 .html