西安电子科技大学数字信号处理上机作业.docx
- 文档编号:8994541
- 上传时间:2023-05-16
- 格式:DOCX
- 页数:11
- 大小:215.74KB
西安电子科技大学数字信号处理上机作业.docx
《西安电子科技大学数字信号处理上机作业.docx》由会员分享,可在线阅读,更多相关《西安电子科技大学数字信号处理上机作业.docx(11页珍藏版)》请在冰点文库上搜索。
西安电子科技大学数字信号处理上机作业
数字信号处理MATLAB上机作业
M2.2
1.题目
ThesquarewaveandthesawtoothwavearetwoperiodicsequencesassketchedinfigureP2.4.Usingthefunctionstem.Theinputdataspecifiedbytheuserare:
desiredlengthLofthesequence,peakvalueA,andtheperiodN.Forthesquarewavesequenceanadditionaluser-specifiedparameteristhedutycycle,whichisthepercentoftheperiodforwhichthesignalispositive.Usingthisprogramgeneratethefirst100samplesofeachoftheabovesequenceswithasamplingrateof20kHz,apeakvalueof7,aperiodof13,andadutycycleof60%forthesquarewave.
2.程序
%用户定义各项参数参数
A=input('Thepeakvalue=');
L=input('Lengthofsequence=');
N=input('Theperiodofsequence=');
FT=input('Thedesiredsamplingfrequency=');
DC=input('Thesquarewavedutycycle=');
%产生所需要的信号
t=0:
L-1;
T=1/FT;
x=A*sawtooth(2*pi*t/N);
y=A*square(2*pi*(t/N),DC);
%Plot
subplot(2,1,1)
stem(t,x);
ylabel('幅度');
xlabel('n');
subplot(2,1,2)
stem(t,y);
ylabel('幅度');
xlabel('n');
3.结果
4.结果分析
M2.4
1.题目
(a)Writeamatlabprogramtogenerateasinusoidalsequencex[n]=Acos(ω0n+Ф)andplotthesequenceusingthestemfunction.TheinputdataspecifiedbytheuserarethedesiredlengthL,amplitudeA,theangularfrequencyω0,andthephaseФwhere0<ω0 (b)GeneratesinusoidalsequenceswiththeangularfrequenciesgiveninProblem2.22.Determinetheperiodofeachsequencefromtheplotandverifytheresulttheoretically. 2.程序 %用户定义的参数 L=input('Desiredlength='); A=input('Amplitude='); omega=input('Angularfrequency='); phi=input('Phase='); %信号产生 n=0: L-1; x=A*cos(omega*n+phi); stem(n,x); xlabel('n');ylabel('幅度'); title(['\omega_{o}= ',num2str(omega)]); 3.结果 (a) ω0=0 ω0=0.1π ω0=0.8π ω0=1.2π (b) ω0=0.14π ω0=0.24π ω0=0.34π ω0=0.68π ω0=0.75π 4.结果分析 M2.5 1.题目 Generatethesequencesofproblem2.21(b)to2.21(e)usingmatlab. 2.程序 (b) n=0: 99; x=sin(0.6*pi*n+0.6*pi); stem(n,x); xlabel('n');ylabel('幅度'); (c) n=0: 99; x=2*cos(1.1*pi*n-0.5*pi)+2*sin(0.7*pi*n); stem(n,x); xlabel('n');ylabel('幅度'); (d) n=0: 99; x=3*sin(1.3*pi*n-4*cos(0.3*pi*n+0.45*pi)); stem(n,x); xlabel('n');ylabel('幅度'); (e) n=0: 99; x=5*sin(1.2*pi*n+0.65*pi)+4*sin(0.8*pi*n)-cos(0.8*pi*n); stem(n,x); xlabel('n');ylabel('幅度'); (f) n=0: 99; x=mod(n,6); stem(n,x); xlabel('n');ylabel('幅度'); 3.结果 (b) (c) (d) (e) (f) 4.结果分析 M2.6 1.题目 Writeamatlabprogramtoplotacontinuous-timesinusoidalsignalanditssampledversionandverifyfigure2.19.Youneedtousetheholdfunctiontokeepbothplots. 2.程序 %用户定义的参数 fo=input('FrequencyofsinusoidinHz='); FT=input('SampligfrequencyinHz='); %产生信号 t=0: 0.001: 1; g1=cos(2*pi*fo*t); plot(t,g1,'-') xlabel('时间t');ylabel('幅度') hold n=0: 1: FT; gs=cos(2*pi*fo*n/FT); plot(n/FT,gs,'o');holdoff 3.结果 4.结果分析 M3.1 1.题目 Usingprogram3_1determineandplottherealandimaginarypartsandthemagnitudeandphasespectraofthefollowingDTFTforvariousvaluesofrandθ: 0 2.程序 %program3_1 %discrete-timefouriertransformcomputatition % k=input('Numberoffrequencypoints='); num=input('Numeratorcoefficients='); den=input('Denominatorcoefficients='); %computerthefrequencyresponse w=0: pi/k: pi; h=freqz(num,den,w); %plotthefrequencyresponse subplot(221) plot(w/pi,real(h));grid title('realpart') xlabel('\omega/\pi');ylabel('Amplitude') subplot(222) plot(w/pi,imag(h));grid title('imaginarypart') xlabel('\omega/\pi');ylabel('Amplitude') subplot(223) plot(w/pi,abs(h));grid title('magnitudespectrum') xlabel('\omega/\pi');ylabel('magnitude') subplot(224) plot(w/pi,angle(h));grid title('phasespectrum') xlabel('\omega/\pi');ylabel('phase,radians') 3.结果 (a)r=0.8θ=π/6 (b)r=0.6θ=π/3 4.结果分析 M3.4 1.题目 UsingmatlabverifythefollowinggeneralpropertiesoftheDTFTaslistedinTable3.2: (a)Linearity,(b)time-shifting,(c)frequency-shifting,(d)differentiation-in-frequency,(e)convolution,(f)modulation,and(g)Parseval’srelation.Sincealldatainmatlabhavetobefinite-lengthvectors,thesequencestobeusedtoverifythepropertiesarethusrestrictedtobeoffinitelength. 2.程序 %先定义两个信号 N=input('Thelengthofthesequence='); k=0: N-1; %g为正弦信号 g=2*sin(2*pi*k/(N/2)); %h为余弦信号 h=3*cos(2*pi*k/(N/2)); 继续阅读
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 西安电子科技大学 数字信号 处理 上机 作业
![提示](https://static.bingdoc.com/images/bang_tan.gif)