MATLAB编程冲击响应卷积DTFT与DFT的比较.docx
《MATLAB编程冲击响应卷积DTFT与DFT的比较.docx》由会员分享,可在线阅读,更多相关《MATLAB编程冲击响应卷积DTFT与DFT的比较.docx(16页珍藏版)》请在冰点文库上搜索。
MATLAB编程冲击响应卷积DTFT与DFT的比较
(1)Usingimpztocalculatey(n):
(N=8,16,32,64,128,256)
TheresultsofN=8,16,32and64areinfigure1.
Figure1.
TheresultsofN=128and256areinfigure2.
Figure2.
(2)Usingconvtocalculatey(n):
(N=8,16,32,64,128,256)
TheresultsofN=8,16,32and64areinfigure3.
Figure3.
TheresultsofN=128and256areinfigure4.
Figure4.
(3)Usingffttocalculatey(n):
(N=8,16,32,64,128,256)
TheresultsofN=8,16,32and64areinfigure5.
Figure5.
TheresultsofN=128and256areinfigure6.
Figure6.
Differencesbetweenimpz,convandfft:
Resultsofimpzandconvareverysimilartoeachother,theonlydifferencebetweenthistwoistherangeoffrequency:
conv’sisalmosttwotimeswiderthanimpz’s.Meanwhiletheresultoffftisquitedifferentfromthatofimpzandconv.WhenvalueofNislarger,thewaveformsoffftaremoresimilartothatofimpzandconv.
(4)Explorezero-padding:
N=8;K=N,1.5*N,2*Nand2*N-1,showninfigure7.
Figure7.
N=16;K=N,1.5*N,2*Nand2*N-1,showninfigure8.
Figure8.
N=32;K=N,1.5*N,2*Nand2*N-1,showninfigure9.
Figure9.
N=64;K=N,1.5*N,2*Nand2*N-1,showninfigure10.
Figure10.
N=128;K=N,1.5*N,2*Nand2*N-1,showninfigure11.
Figure11.
N=256;K=N,1.5*N,2*Nand2*N-1,showninfigure12.
Figure12.
Comment:
Fromaboveresults,wecanfindthatwhenthevalueofKisincreasing,theresultoffftbecomesmoresamelikethatofconv;andthenwhenKisequalto2*N-1,bothconvandfftprovidethesameresults.SincewhenKincreases,thenumberofsamplingpointsinthefrequencydomainincreases,whichrenderssmallerfrequencyinterval.Hence,thespectrumdensitywillaugmentandtheresultsoffftgraduallybecomethesameasthatofconv.
Accordingtotheanalysisabove,wecanfindwhenK=256impzandconv’sresultsaresame,andwhenK=2*N-1,fftandconv’sresultsaresame,thus,theconclusionis,whenK=256andK=2*N-1,allthreemethodsproducethesameresult.
Code:
1.Usingimpztocalculatey(n):
forN=8,16,32,64
>>a0=0.95;
>>a=[1-a0];
>>b=[1-a0];
>>c0=pi/13;
>>c1=0.95;
>>c2=cos(c0);
>>c=[1-c1*c2];
>>d=[1-2*c1*c2c1^2];
>>L=100;
>>NFFT=2^nextpow2(L);
>>N=8;
>>aa=a*b;
>>bb=conv(c,d);
>>y=impz(aa,bb,N);
>>y1=impz(aa,bb,N*2);
>>y2=impz(aa,bb,N*4);
>>y3=impz(aa,bb,N*8);
>>subplot(221);
>>stem(y)
>>title('impulseresponseN=8')
>>subplot(222);
>>stem(y1)
>>title('impulseresponseN=16')
>>subplot(223);
>>stem(y2)
>>title('impulseresponseN=32')
>>subplot(224);
>>stem(y3)
>>title('impulseresponseN=64')
forN=128,256
>>a0=0.95;
>>a=[1-a0];
>>b=[1-a0];
>>c0=pi/13;
>>c1=0.95;
>>c2=cos(c0);
>>c=[1-c1*c2];
>>d=[1-2*c1*c2c1^2];
>>L=100;
>>NFFT=2^nextpow2(L);
>>N=8;
>>aa=a*b;
>>bb=conv(c,d);
>>y4=impz(aa,bb,N*16);
>>y5=impz(aa,bb,N*32);
>>subplot(221);
>>stem(y4(1:
128))
>>title('impulseresponseN=128')
>>subplot(222);
>>stem(y5(1:
128))
>>title('impulseresponseN=256')
2.Usingconvtocalculatey(n):
forN=8,16,32,64
>>a0=0.95;
>>a=[1-a0];
>>b=[1-a0];
>>c0=pi/13;
>>c1=0.95;
>>c2=cos(c0);
>>c=[1-c1*c2];
>>d=[1-2*c1*c2c1^2];
>>L=100;
>>NFFT=2^nextpow2(L);
>>N=8;
>>x=impz(a,b,N);
>>h=impz(c,d,N);
>>y=conv(x,h);
>>subplot(221)
>>stem(y)
>>title('convolutionN=8')
>>x1=impz(a,b,N*2);
>>h1=impz(c,d,N*2);
>>y1=conv(x1,h1);
>>subplot(222)
>>stem(y1)
>>title('convolutionN=16')
>>x2=impz(a,b,N*4);
>>h2=impz(c,d,N*4);
>>y2=conv(x2,h2);
>>subplot(223)
>>stem(y2)
>>title('convolutionN=32')
>>x3=impz(a,b,N*8);
>>h3=impz(c,d,N*8);
>>y3=conv(x3,h3);
>>subplot(224)
>>stem(y3)
>>title('convolutionN=64')
forN=128,256
>>a0=0.95;
>>a=[1-a0];
>>b=[1-a0];
>>c0=pi/13;
>>c1=0.95;
>>c2=cos(c0);
>>c=[1-c1*c2];
>>d=[1-2*c1*c2c1^2];
>>L=100;
>>NFFT=2^nextpow2(L);
>>N=8;
>>x=impz(a,b,N*16);
>>h=impz(c,d,N*16);
>>y=conv(x,h);
>>subplot(221)
>>stem(y(1:
128))
>>title('convolutionN=128')
>>x1=impz(a,b,N*32);
>>h1=impz(c,d,N*32);
>>y1=conv(x1,h1);
>>subplot(222)
>>stem(y1(1:
128))
>>title('convolutionN=256')
3.Usingffttocalculatey(n):
forN=8,16,32,64
>>a0=0.95;
>>a=[1-a0];
>>b=[1-a0];
>>c0=pi/13;
>>c1=0.95;
>>c2=cos(c0);
>>c=[1-c1*c2];
>>d=[1-2*c1*c2c1^2];
>>L=100;
>>NFFT=2^nextpow2(L);
>>N=8;
>>x1=impz(a,b,N);
>>h1=impz(c,d,N);
>>y11=fft(x1,NFFT);
>>y21=fft(h1,NFFT);
>>y31=times(y11,y21);
>>y1=ifft(y31);
>>subplot(221);
>>stem(y1)
>>title('fftN=8')
>>x2=impz(a,b,N*2);
>>h2=impz(c,d,N*2);
>>y12=fft(x2,NFFT);
>>y22=fft(h2,NFFT);
>>y32=times(y12,y22);
>>y2=ifft(y32);
>>subplot(222);
>>stem(y2)
>>title('fftN=16')
>>x3=impz(a,b,N*4);
>>h3=impz(c,d,N*4);
>>y13=fft(x3,NFFT);
>>y23=fft(h3,NFFT);
>>y33=times(y13,y23);
>>y3=ifft(y33);
>>subplot(223);
>>stem(y3)
>>title('fftN=32')
>>x4=impz(a,b,N*8);
>>h4=impz(c,d,N*8);
>>y14=fft(x4,NFFT);
>>y24=fft(h4,NFFT);
>>y34=times(y14,y24);
>>y4=ifft(y34);
>>subplot(224);
>>stem(y4)
>>title('fftN=64')
forN=128,256
>>a0=0.95;
>>a=[1-a0];
>>b=[1-a0];
>>c0=pi/13;
>>c1=0.95;
>>c2=cos(c0);
>>c=[1-c1*c2];
>>d=[1-2*c1*c2c1^2];
>>L=100;
>>NFFT=2^nextpow2(L);
>>N=8;
>>x1=impz(a,b,N*16);
>>h1=impz(c,d,N*16);
>>y11=fft(x1,NFFT);
>>y21=fft(h1,NFFT);
>>y31=times(y11,y21);
>>y1=ifft(y31);
>>subplot(221);
>>stem(y1)
>>title('fftN=128')
>>x2=impz(a,b,N*32);
>>h2=impz(c,d,N*32);
>>y12=fft(x2,NFFT);
>>y22=fft(h2,NFFT);
>>y32=times(y12,y22);
>>y2=ifft(y32);
>>subplot(222);
>>stem(y2)
>>title('fftN=256')
4:
Explorezero-paddingusingK-pointDFT
N=8,16,32,64,128and256
K=N,1.5*N,2*Nand2*N-1
>>a0=0.95;
>>a=[1-a0];
>>b=[1-a0];
>>c0=pi/13;
>>c1=0.95;
>>c2=cos(c0);
>>c=[1-c1*c2];
>>d=[1-2*c1*c2c1^2];
>>N=8;
>>K1=N;
>>x=impz(a,b,N);
>>h=impz(c,d,N);
>>y11=conv(x,h);
>>y121=fft(x,K1);
>>y122=fft(h,K1);
>>y123=times(y121,y122);
>>y12=ifft(y123);
>>subplot(221);
>>plot(y11);
>>holdon;
>>stem(y12);
>>holdoff;
>>title('N=K,plotresultofconvandstemresultoffft')
>>K2=1.5*N;
>>y21=conv(x,h);
>>y221=fft(x,K2);
>>y222=fft(h,K2);
>>y223=times(y221,y222);
>>y22=ifft(y223);
>>subplot(222)
>>plot(y21);
>>holdon;
>>stem(y22);
>>holdoff;
>>title('K=1.5*N,plotresultofconvandstemresultoffft')
>>K3=2*N;
>>y31=conv(x,h);
>>y321=fft(x,K3);
>>y322=fft(h,K3);
>>y323=times(y321,y322);
>>y32=ifft(y323);
>>subplot(223)
>>plot(y31);
>>holdon;
>>stem(y32);
>>holdoff;
>>title('K=2*N,plotresultofconvandstemresultoffft')
>>K4=2*N-1;
>>y41=conv(x,h);
>>y421=fft(x,K4);
>>y422=fft(h,K4);
>>y423=times(y421,y422);
>>y42=ifft(y423);
>>subplot(224)
>>plot(y41);
>>holdon;
>>stem(y42);
>>holdoff;
>>title('K=2*N-1,plotresultofconvandstemresultoffft')