You are on page 1of 3

Reg

no.- 11113011

AIM:-Generate DFT & IDFT

1)DFT:clc;
clear all;
x=input('enter the sequence');
N=length(x);
for k=1:N
x(k)=0;
for n=1:N
x(k)=x(k)+x(n)*exp(-j*2*pi*(k-1)*(n-1)/N);
end
end
disp(abs(x));
subplot(3,1,1);
stem(abs(x));
subplot(3,1,2);
disp(angle(x));
stem(angle(x));

Command window:enter the sequence[2,3,4,5]


12.0000 10.6301 14.3178 24.1661
0 -0.7188 1.3597 -1.1442

Graph:30
20
10
0

1.5

2.5

3.5

1.5

2.5

3.5

2
1
0
-1
-2
1

2)IDFT:clc;
clear all;
x=input('enter the sequence');
N=length(x);
for n=1:N
x(n)=0;

for k=1:N
x(n)=x(n)+x(k)*exp(j*2*pi*(n-1)*(k-1)/N);
end
end
disp(abs(x));
subplot(3,1,1);
stem(abs(x));
subplot(3,1,2);
disp(angle(x));
stem(angle(x));

Command window:enter the sequence[3,4,5,1]


10.0000 10.2956 20.1246 23.1948
0 1.0637 -1.1071 1.7005

Graph:30
20
10
0

1.5

2.5

3.5

1.5

2.5

3.5

2
1
0
-1
-2
1

30
20
10
0

1 .5

2 .5

3 .5

1 .5

2 .5

3 .5

2
1
0
-1
-2

You might also like