資源描述:
《數(shù)字信號處理大作業(yè)分析》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、數(shù)字信號處理大作業(yè)電子工程學院M2.2ThesquarewaveandthesawtoothwavearetwoperiodicsequenceassketchedinFigureP2.1.UsingthefunctionssawtoothandsquarewriteaMATLABprogramtogeneratetheabovetwosequencesandplotthemandtheperiodN.Forthesquarewavesequenceanadditionaluser-specifiedparame
2、teristhedutycycle,whileisthepercentoftheperiodforwhichthesignalispositive.Usingthisprogramgeneratethefirst100samplesofeachoftheabovesequenceswithasamplingrateof20khz,apeakvalueof7,aperiodof13andadutycycleof60%forthesquarewave.如下為matlab程序代碼:%getuserinputsa=inp
3、ut('thepeakvalue=');l=input('lengthofsequence=');n=input('theperiodofsequence');ft=input('thedesiredsamplingfrequency=');dc=input('thesquarewavedutycycle=');%creatsingalst=1/ft;t=0:l-1;x=a*sawtooth(2*pi*t/n);y=a*square(2*pi*(t/n),dc);%poltsubplot(211)stem(t,x
4、)ylabel('Amplitude');xlabel(['Timein',num2str(t),'sec']);subplot(212)stem(t,y);ylabel('Amplitude');xlabel(['Timein',num2str(t),'sec']);在仿真之前,分析題目中所給出的數(shù)據(jù),需要注意此時的周期為序列的個數(shù)13,而非時間周期13s,否則100個取樣最終時間才花費0.05s,在圖中就無法顯示出來。同時占空比很明確的影響方波的取樣正負所占比例,這也與占空比所本意相吻合。周期的多少也直接影響
5、一個周期內(nèi)取樣的個數(shù)。M2.4(a)WriteaMatlabprogramtogenerateasinusoidalsequencex[n]=Acos(ω0n+φ)andplotthesequenceusingthestemfunction.TheinputdataspecifiedbytheuserarethedesiredlengthL,amplitudeA,theangularfrequencyω0,andthephaseφwhere0<ω0<πand0≤φ≤2π.Usingtheprogramgenera
6、tethesinusoidalsequenceshowninfigure2.15.(b)Generatesinusoidalsequenceswiththeangularfrequenciesgiveninproblem2.2.Determinetheperiodofeachsequencefromtheplotandverifytheresulttheoretically.Answer:如下為matlab代碼:>>L=input('Desiredlength=');A=input('Amplitude=');o
7、mega=input('Angularfrequency=');phi=input('Phase=');n=0:L-1;x=A*cos(omega*n+phi);stem(n,x);xlabel('Timeindex');ylabel('Amplitude');title(['omega_{o}=',num2str(omega)]);%%example:Desiredlength=100Amplitude=1.5Angularfrequency=0.1*piPhase=0ω0=0.1πω0=0.14π由理論計算
8、可知其周期t=2pi/0.14pi=100/7,故時間周期T=100,由圖中也可明顯看出,其波形以100開始循壞,故其周期也為100,相符。.ω0=0.24π理論計算t=2pi/0.24pi=25/3,故其周期為25,由圖中也可看出,其圖像每25一循壞,周期為25,與理論也相符。w0=0.34pi理論計算t=2pi/0.34pi=100/17,故其周期為100,由圖中,基