matlab dtft dft等代码实验报告.docx

上传人:b****8 文档编号:9608787 上传时间:2023-05-20 格式:DOCX 页数:15 大小:59.13KB
下载 相关 举报
matlab dtft dft等代码实验报告.docx_第1页
第1页 / 共15页
matlab dtft dft等代码实验报告.docx_第2页
第2页 / 共15页
matlab dtft dft等代码实验报告.docx_第3页
第3页 / 共15页
matlab dtft dft等代码实验报告.docx_第4页
第4页 / 共15页
matlab dtft dft等代码实验报告.docx_第5页
第5页 / 共15页
matlab dtft dft等代码实验报告.docx_第6页
第6页 / 共15页
matlab dtft dft等代码实验报告.docx_第7页
第7页 / 共15页
matlab dtft dft等代码实验报告.docx_第8页
第8页 / 共15页
matlab dtft dft等代码实验报告.docx_第9页
第9页 / 共15页
matlab dtft dft等代码实验报告.docx_第10页
第10页 / 共15页
matlab dtft dft等代码实验报告.docx_第11页
第11页 / 共15页
matlab dtft dft等代码实验报告.docx_第12页
第12页 / 共15页
matlab dtft dft等代码实验报告.docx_第13页
第13页 / 共15页
matlab dtft dft等代码实验报告.docx_第14页
第14页 / 共15页
matlab dtft dft等代码实验报告.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

matlab dtft dft等代码实验报告.docx

《matlab dtft dft等代码实验报告.docx》由会员分享,可在线阅读,更多相关《matlab dtft dft等代码实验报告.docx(15页珍藏版)》请在冰点文库上搜索。

matlab dtft dft等代码实验报告.docx

matlabdtftdft等代码实验报告

 

LaboratoryReportofDigitalSignalProcessing

LabII.FourieranalysisinMATLAB

 

Name:

廖艺灵

No.:

5100309716

Date:

2013/4/6

 

SHANGHAIJIAOTONGUNIVERSITY

DepartmentofInstrumentScience&Engineering

Content

1Introduction1

2Exercises1

Ex.1CreateaTriangleSignal1

Ex.2CTFTAndCTFS1

Ex.3DTFT1

Ex.4DFT1

3ResultsandDiscussion2

Ex.1CreateaTriangleSignal2

Ex.2CTFTAndCTFS2

Ex.3DTFT4

Ex.4DFT5

4Summary7

5Reference7

6Appendix8

Ex.1CreateaTriangleSignal8

Ex.3DTFT9

Ex.4DFT10

1Introduction

ThislabconcentratesmainlyontheFourieranalysisinMATLAB.Foreachkindofsignals,e.g.discreteorcontinuoustimesignalsandperiodicornon-periodicsignals,thecorrespondingFourieranalysismaybeContinuous-TimeFourierSeries(CTFS),Discrete-TimeFourierSeries(DTFS),Continuous-TimeFourierTransform(CTFT),Discrete-TimeFourierTransform(DTFT)andDiscreteFourierTransform(DFT).Refertotheexamplewhichusessquaresignalastheinputsignal,wewilluseatrianglewavetoachievesamegoals,thatisfinditsCTFS,DTFS,CTFT,DTFTandDFTtocomparethedifferencesbetweenthem.TheMatlabcodesfortheseFourieranalysiscalculationsareprovidedinscriptfilesasfollows.

2Exercises

Ex.1CreateaTriangleSignal

1.1RefertomySquare.m,developasub-functionmyTriangle.mforaperiodicisoscelestriangle(seeFig.1asdemonstration)withproperinputsandoutputs.Providethewholecodesinthereportappendix.

1.2RunmyTriangle.mtocreateacontinuousperiodictrianglewiththeheightH=1.5,lengthL=2andperiodT=5.Showtheresultwithatleast3cycles.

Fig.1TriangleWave

Ex.2CTFTAndCTFS

2.1RunCTFS.mforthisperiodictriangleandCTFT.mforonlyonetrianglesignal.CalculateandshowtheFouriercoefficients(includingatleast99%averagepower)andspectrum(includingatleast99%ofenergy),respectively.

2.2ExplaintherelationshipbetweentheCTFTandCTFS.

Ex.3DTFT

3.1RefertoCTFT.m,developDTFT.mfordiscrete-timeFouriertransform.Adiscrete-timetrianglesignalobtainedfrommyTriangleischosenasanexamplesignalinDTFT.Providethewholecodesinthereportappendix.

3.2RunDTFT.mofthesampledonetriangleofEx.1withasamplingfrequencyoffs=10.ShowandcomparetheDTFTresultswiththosefromCTFTofthecorrespondingCTtriangle.

3.3ExplaintherelationshipbetweentheDTFTandCTFT.

Ex.4DFT

4.1RefertoCTFT.m,developasub-functionofmyDFT.mfordiscreteFouriertransformwithproperinputsandoutputs.Providethewholecodesinthereportappendix.

4.2RunDFT.mofthesampledonetriangleofEx.1withasamplingfrequencyoffs=10.ShowandcomparetheDFTresultswiththosefromDTFT.

4.3ExplaintherelationshipbetweentheDFTandDTFT.

3ResultsandDiscussion

Ex.1CreateaTriangleSignal

Thefunctioncodesareputintheappendix.Followingistheoutputfigureofthefunction.

Fig.2TheTriangleSignal

Ex.2CTFTAndCTFS

CTFT

CTFS

TimeDomain

Continuous

Aperiodic

Continuous

Periodic

FrequencyDomain

Continuous

Aperiodic

Discrete

Aperiodic

BetweentheCTFSandCTFT,weprefertohavetheCTFTbecauseithasallthe

informationcontainedintheCTFSontheassumptionthattheCTFSconsistsof

thesamplesofCTFT.Besides,theCTFSisnotsopracticalbecauseitishardtofindtheperiod.

Fig.3FourierCoefficients

 

Fig.4TheReconstructedTriangleWavewith10-orderHarmonics.

Fig.5FourierTransformofaContinuousTriangleSignal.

Ex.3DTFT

CTFT

DTFT

TimeDomain

Continuous

Aperiodic

Discrete

Aperiodic

FrequencyDomain

Continuous

Aperiodic

Continuous

Periodic

theDTFTofx[n]=x(nT)isqualitativelytheperiodicextensionoftheCTFTofx(t)(withperiod2π/Tinanalogfrequencyωor2πindigitalfrequencyΩ),thesumofinfinitelymanyshiftedversionofCTFT.ThisexplainshowtheDTFTstraysfromtheCTFTbecauseoffrequency-aliasingDiscrete-TimeFourierAnalysis

Fig.6DTFTofaTriangleSignal

Ex.4DFT

DTFT

DFT

TimeDomain

Discrete

Aperiodic

Discrete

Aperiodic

FrequencyDomain

Continuous

Periodic

Discrete

Periodic

DTFTaftertransformationfrequencyofagraphicisgenerallysequential,andintervalsampling,suchasDFTisDTFTisdiscretepoints.Fromthesaid,youcanseethatitsfunctionisexpressedasX(k),andDTFTfunctionisexpressedastheX(exp(jw)).(heregivesprominencetothesamplinginterval,suchasDFTisDTFTDTFTfrequencyresponseisgenerallystraightafterthechange,afterDFTtransformoffrequencyresponseisdiscrete).DTFTis2PIforthecycle.AndsequenceofDFTX(k)islimited.

Fig.7ComparisonofDFTandDTFTofaTriangleSignal.

 

4Summary

WecouldmakeatabletoshowthemajorfeatureoftheseFouriertransforms.

CTFT

CTFS

DTFT

DTFS

DFT

TimeDomain

Continuous

Aperiodic

Continuous

Periodic

Discrete

Aperiodic

Discrete

Periodic

Discrete

Aperiodic

FrequencyDomain

Continuous

Aperiodic

Discrete

Aperiodic

Continuous

Periodic

Discrete

Periodic

Discrete

Periodic

Whenanalyzeanysignal,weshoulduseproperFouriertransformtohelpusfindtheexactanswer.

5Reference

[1]MATLABGettingStartedGuideCOPYRIGHT1984-2010byTheMathWorks,Inc

[2]A.V.Oppenheim,A.S.WillskyandS.H.Nawab,SignalsandSystems(SecondEdition),PublishingHouseofElectricsIndustry

 

6Appendix

Ex.1CreateaTriangleSignal

%%==================================================================

%MYTRIANGLEusedtocreateatrianglewavewithncylces.

%byTramps,30/03/2013

%%==================================================================

%%

function[x,t]=myTriangle(para)

%%inputparameters

paraDef=struct('H',1.5,'T',5,'L',2,'n',3,'fs',100);

bDef=0;%plotthesignal?

0:

no,1:

yes

%noinputparameter

ifnargin<1,

para=paraDef;

bDef=1;

end

%gettheparametersforthesquaresignal

ifisstruct(para)

H=para.H;

T=para.T;

L=para.L;

n=para.n;

fs=para.fs;

else

para=paraDef;

bDef=1;

end

%%createoneperiodofthesignal

dt=1/fs;

tp=(-T/2+dt):

dt:

T/2;

xp=zeros(1,length(tp))

lp=-L/2:

dt:

L/2;

forii=1:

(length(lp)-1)

xp(fs*(T-L)/2+ii)=H*(fs*L-ii)/fs;

xp(fs*(T+L)/2-ii)=H*(fs*L-ii)/fs;

end

%plot(tp,xp);

%return

%%Createall-timesignalbyreplicatingonecyclethroughconvolution

ta=(-n*T/2+dt):

dt:

n*T/2;

xa=zeros(1,length(ta));

forii=0:

n-1

tmp=ii*fs*T;

xa((tmp+1):

(tmp+T*fs))=xp;

end

%plot(ta,xa);

%return

%%outputresults

t=ta;

x=xa;

if(bDef)

plot(t,x)

set(gca,'YLim',[-H*0.1,H*1.1])

title('DefaultTriangleSignal')

end

end

Ex.3DTFT

%========================================================================

%1)CalculatetheDiscrete-TimeFourierTransform(DTFT)ofatrianglesignal.

%2)ChecktheParseval'srelationforFouriertransform.

%byTramps,30/03/2013

%========================================================================

%%

clc,clear,closeall

%%Createatrianglewavewithjustonecycle

%

(1)setparameters

H=1;%height

T=5;%cycletime

L=2;%length

n=1;%numberofcycles(1.2.3...)

fs=10;%samplingfrequency

%

(2)createthetriangle

para=struct('H',H,'T',T,'L',L,'n',n,'fs',fs);

[xp,tp]=myTriangle(para);

%stem(tp,xp);

%%FT

N=fs*T;

k=-N:

N;

FT_w=-3*pi:

0.1:

3*pi;

DTFT_FT=0;

forii=1:

N

DTFT_FTtmp=xp(ii)*exp(-1j*FT_w*k(ii));

DTFT_FT=DTFT_FT+DTFT_FTtmp;

end

%%showresults

figure;

%

subplot(211);%timedomain

stem(tp,xp,'r');

xlabel('t(s)');

ylabel('Amplitude');

title('Discrete-TimeTriangleSignal');

gridon;

%

subplot(212);%frequencydomain

plot(FT_w/(2*pi),abs(DTFT_FT),'r');

xlabel('f');

ylabel('|X(j\omega)|');

title('Spectrum(DTFT)');

gridon;

%%end

Ex.4DFT

%%=====================================================================

%DTFTvsDFTbytrianglesignal

%byTramps,30/03/2013

%%=====================================================================

%%

clc,clear,closeall

%%createatrianglesignal

%

(1)setparameters

H=1;%height

T=5;%cycletime

L=2;%length

n=1;%numberofcycles(1.2.3...)

fs=10;%samplingfrequency

%

(2)createthesignals

para=struct('H',H,'T',T,'L',L,'n',1,'fs',fs);

[x_D,t_D]=myTriangle(para);%DTFT

%stem(t_D,x_D);

%%DTFT

N=fs*T;

k=-N:

N;

DTFT_w=-3*pi:

0.1:

3*pi;

DTFT_FT=0;

forii=1:

N

DTFT_FTtmp=x_D(ii)*exp(-1j*DTFT_w*k(ii));

DTFT_FT=DTFT_FT+DTFT_FTtmp;

end

%plot(DTFT_w/(2*pi),abs(DTFT_FT),'r');

%%DFT

N_DFT=64;

[X_DFT,w,f]=myDFT(x_D,N_DFT,100);

%stem(w/(2*pi),abs(X_DFT),'r');

%%showresults

figure;

%

subplot(311);

stem(t_D,x_D,'r');%DTFTtimedomain

xlabel('t(s)');

ylabel('Amplitude');

title('Discrete-TimeTriangleSignal');

gridon;

%

subplot(312);

plot(DTFT_w/(2*pi),abs(DTFT_FT),'r');%DTFTfrequencydomain

xlabel('f');

ylabel('|X(j\omega)|');

title('Spectrum(DTFT)');

gridon;

%

subplot(313);

stem(w/(2*pi),abs(X_DFT),'r');%DFTfrequencydomain

xlabel('f');

ylabel('|X(j\omega)|');

title('DFT');

gridon;

%%end

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 工程科技 > 城乡园林规划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2