www.pudn.com > voiceprocessingtoolbox.rar > fftZeroPadding04.m
% This example demos the effect of zero padding figure x = [1,1,1,1]; w = [0:1:500]*2*pi/500; H = freqz(x,1,w); magnitude = abs(H); phase = angle(H); %phase(126)=-47.5841*pi/180; subplot(2,1,1); plot(w/pi,magnitude); grid xlabel('Frequency in \pi units'); ylabel('|X|'); title('Magnitude of the DTFT') subplot(2,1,2); plot(w/pi,phase/pi*180); grid xlabel('Frequency in \pi units'); ylabel('Degrees'); title('Angle of the DTFT') figure N = 4; w1 = 2*pi/N; k = 0:N-1; X = fft(x,N); magX = abs(X), phaX = angle(X)*180/pi subplot(2,1,1);plot(w*N/(2*pi),magX,'--'); axis([-0.1,4.1,-1,5]); hold on stem(k,magX); xlabel('k'); ylabel('|X(k)|'); title('Magnitude of the DFT: N=4') hold off subplot(2,1,2);plot(w*N/(2*pi),phaX*180/pi,'--'); axis([-0.1,4.1,-200,200]); hold on stem(k,phaX); xlabel('k'); ylabel('Degrees'); title(sprintf('Angle of the DFT: N=%d', N)); figure N = 10; w1 = 2*pi/N; k = 0:N-1; X = fft(x,N); magX = abs(X), phaX = angle(X)*180/pi subplot(2,1,1);plot(w*N/(2*pi),magX,'--'); axis([-0.1,4.1,-1,5]); hold on stem(k,magX); xlabel('k'); ylabel('|X(k)|'); title(sprintf('Magnitude of the DFT: N=%d', N)) hold off subplot(2,1,2);plot(w*N/(2*pi),phaX*180/pi,'--'); axis([-0.1,4.1,-200,200]); hold on stem(k,phaX); xlabel('k'); ylabel('Degrees'); title(sprintf('Angle of the DFT: N=%d', N));