1、MATLAB编程冲击响应卷积DTFT与DFT的比较(1) Using impz to calculate y(n): (N=8,16,32,64,128,256)The results of N=8, 16, 32 and 64 are in figure 1. Figure 1.The results of N=128 and 256 are in figure 2. Figure 2.(2) Using conv to calculate y(n): (N=8,16,32,64,128,256)The results of N=8, 16, 32 and 64 are in figure
2、3. Figure 3.The results of N=128 and 256 are in figure 4.Figure 4.(3) Using fft to calculate y(n): (N=8,16,32,64,128,256)The results of N=8, 16, 32 and 64 are in figure 5.Figure 5.The results of N=128 and 256 are in figure 6.Figure 6.Differences between impz, conv and fft: Results of impz and conv a
3、re very similar to each other, the only difference between this two is the range of frequency: convs is almost two times wider than impzs. Meanwhile the result of fft is quite different from that of impz and conv. When value of N is larger, the waveforms of fft are more similar to that of impz and c
4、onv.(4) Explore zero-padding: N=8; K=N, 1.5*N, 2*N and 2*N-1, shown in figure 7.Figure 7.N=16; K=N, 1.5*N, 2*N and 2*N-1, shown in figure8.Figure 8.N=32; K=N, 1.5*N, 2*N and 2*N-1, shown in figure 9.Figure 9.N=64; K=N, 1.5*N, 2*N and 2*N-1, shown in figure 10.Figure 10.N=128; K=N, 1.5*N, 2*N and 2*N
5、-1, shown in figure 11.Figure 11.N=256; K=N, 1.5*N, 2*N and 2*N-1, shown in figure 12.Figure 12.Comment:From above results, we can find that when the value of K is increasing, the result of fft becomes more same like that of conv; and then when K is equal to 2*N-1, both conv and fft provide the same
6、 results. Since when K increases, the number of sampling points in the frequency domain increases, which renders smaller frequency interval. Hence, the spectrum density will augment and the results of fft gradually become the same as that of conv.According to the analysis above, we can find when K=2
7、56 impz and convs results are same, and when K=2*N-1, fft and convs results are same, thus, the conclusion is ,when K=256 and K=2*N-1, all three methods produce the same result.Code:1. Using impz to calculate y(n): for N=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;
8、 d=1 -2*c1*c2 c12; L=100; NFFT=2nextpow2(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(impulse response N=8) subplot(222); stem(y1) title(impulse response N=16) subplot(223); stem(y2) title(impulse response N=3
9、2) subplot(224); stem(y3) title(impulse response N=64) for N=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*c2 c12; L=100; NFFT=2nextpow2(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(impulse resp
10、onse N=128) subplot(222); stem (y5 (1:128) title(impulse response N=256)2. Using conv to calculate y(n): for N=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*c2 c12; L=100; NFFT=2nextpow2(L); N=8; x=impz(a,b,N); h=impz(c,d,N); y=conv(x,h); subplot(221) stem
11、(y) title(convolution N=8) x1=impz(a,b,N*2); h1=impz(c,d,N*2); y1=conv(x1,h1); subplot(222) stem(y1) title(convolution N=16) x2=impz(a,b,N*4); h2=impz(c,d,N*4); y2=conv(x2,h2); subplot(223) stem(y2) title(convolution N=32) x3=impz(a,b,N*8); h3=impz(c,d,N*8); y3=conv(x3,h3); subplot(224) stem(y3) tit
12、le(convolution N=64) for N=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*c2 c12; L=100; NFFT=2nextpow2(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(convolution N=128) x1=impz(a,b,N*32); h1=impz(c,d,N*32); y1=conv
13、(x1,h1); subplot(222) stem(y1 (1:128) title(convolution N=256)3.Using fft to calculate y(n): for N=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*c2 c12; L=100; NFFT=2nextpow2(L); N=8; x1=impz(a,b,N); h1=impz(c,d,N); y11=fft(x1,NFFT); y21=fft(h1,NFFT); y31=
14、times(y11,y21); y1=ifft(y31); subplot(221); stem(y1) title(fft N=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(fft N=16) x3=impz(a,b,N*4); h3=impz(c,d,N*4); y13=fft(x3,NFFT); y23=fft(h3,NFFT); y33=times(y13,y
15、23); y3=ifft(y33); subplot(223); stem(y3) title(fft N=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(fft N=64) for N=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*c2 c
16、12; L=100; NFFT=2nextpow2(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(fft N=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(2
17、22); stem(y2) title(fft N=256)4: Explore zero-padding using K-point DFT N=8, 16, 32, 64, 128 and 256 K=N, 1.5*N, 2*N and 2*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*c2 c12; 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)
18、; y123=times(y121,y122); y12=ifft(y123); subplot(221); plot(y11); hold on; stem(y12); hold off; title(N=K, plot result of conv and stem result of fft) 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); hold on; stem(y22); hold off;
19、 title(K=1.5*N, plot result of conv and stem result of fft) 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); hold on; stem(y32); hold off; title(K=2*N, plot result of conv and stem result of fft) 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); hold on; stem(y42); hold off; title(K=2*N-1, plot result of conv and stem result of fft)
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2