Blogger Widgets

Monday 30 April 2012

DFT & IDFT Using Twiddle Factor

MATLAB CODE:
clc
close all
clear all
X=input('Enter the sequence :');
L=input('Enter the length:');
lx=length(X);
x1=[X,zeros(1,L-lx)];
w=(-1j*2*pi/L);
subplot(5,1,1);
stem(X);
legend('Input Sequences');

for n=0:L-1;
    for k=0:L-1;
        w1(n+1,k+1)=w^(n*k);
    end
end
DFTX=x1*w1;
subplot(5,1,2);
stem(abs(DFTX));
legend('amplitude plot of DFT');
subplot(5,1,3);
stem(angle(DFTX));
legend('phase plot of DFT');

W2=(j*2*pi/L);
for n=0:L-1;
    for k=0:L-1;
        w3(n+1,k+1)=w^(n*k);
    end
end

IDFTX=(DFTX*w3)/L;
subplot(5,1,4);
stem(abs(IDFTX));
legend('Amplitude plot for IDFT');
subplot(5,1,5);
stem(angle(IDFTX));
legend('Phase plot for IDFT');
Input:
enter the sequence: [1 2 3 4]
enter the length: 4


Figure:-

0 comments

Post a Comment