You are on page 1of 2

Program:

% Fast fourier transform - DIT using in-built function


clc;
clear all;
x=input('Enter the input sequence:');
N=length(x);
y=fft(x,N);
disp('FFT-DIT o/p using in-built fn:');
disp(y);

% FFT-DIT using algorithm


y=bitrevorder(x);
w1=1;
w2=0.707-0.707j;
w3=-1j;
w4=-0.707-0.707j;

for K=1:2:N
s1(K)=y(K)+y(K+1);
s1(K+1)=y(K)-y(K+1);
end
disp('o/p of 1st stage');
disp(s1);

for K=1:4:N
s2(K)=s1(K)+s1(K+2);
s2(K+1)=s1(K+1)+w3*s1(K+3);
s2(K+2)=s1(K)-s1(K+2);
s2(K+3)=s1(K+1)-w3*s1(K+3);
end
disp('o/p of 2nd stage');
disp(s2);

%calculation of stage 3
for K=1:8:N
s3(K)=s2(K)+s2(K+4);
s3(K+1)=s2(K+1)+w2*s2(K+5);
s3(K+2)=s2(K+2)+w3*s2(K+6);
s3(K+3)=s2(K+3)+w4*s2(K+7);
s3(K+4)=s2(K)-s2(K+4);
s3(K+5)=s2(K+1)-w2*s2(K+5);
s3(K+6)=s2(K+2)-w3*s2(K+6);
s3(K+7)=s2(K+3)-w4*s2(K+7);
end
disp('o/p of 3rd stage :');
disp(s3);

%magnitude and phase plot


disp('magnitude and phase response of FFT-DIT sequence:');
subplot(2,1,1);
stem(20*log10(abs(s3)));
title('Magnitude plot');
xlabel('sample(n)');
ylabel('magnitude');
subplot(2,1,2);
stem(angle(s3));
title('phase plot');
xlabel('sample(n)');
ylabel('phase');

You might also like