EXPERIMENT - 14
AIM
To demonstrate 8 point DFT using for loop and verify it using FFT command in MATLAB.
THEORY
DFT (Discrete Fourier Transform) is very important technique used in Digital Signal Processing. N point DFT of x(n) is given by
where goes from 0 to N-1
MATLAB COMMANDS USED
* plot(x,y,color,properties)
* exp(-j*t);
* fft(x,n)
* stem(x)
* sum(x)
MATLAB CODE
% Finding 8 point DFT using a loop
N=8;
x=[ 2 -1 1 3 -2 1 2 0];
n=-0:N-1;
for k=0:N-1
W=exp(-j*2*pi*k*n/N); % Twiddle factor
prod=x.*W;
X(k+1)=sum(prod);
end
subplot(2,1,1)
stem(n,abs(X),'black','filled');
title('Magnitude spectrum of 8 point DFT');
subplot(2,1,2)
stem(n,abs(fft(x,8)),'black','filled');
title('Magnitude spectrum of 8 point DFT using fft command.');
RESULT
The 8 point DFT has been using loop and verified using FFT command in MATLAB.