You are on page 1of 3

Matlab program to perform radix-2 FFT

clc
clear all
x=[1 2 3 4 4 3 2 1];
l=length(x);
j=1;
for i=1:(l/2)
xvn(i)=x(j);
xod(i)=x(j+1);
j=j+2;
end
j=1;
for i=1:(l/4)
xvnvn(i)=xvn(j);
xvnod(i)=xvn(j+1);
j=j+2;
end
j=1;
for i=1:(l/4)
xodvn(i)=xod(j);
xodod(i)=xod(j+1);
j=j+2;
end
for i=1:2
A(i)=xvnvn(1)+((-1)^(i+1))*xvnvn(2)
end
for i=1:2
B(i)=xvnod(1)+((-1)^(i+1))*xvnod(2)
end
for i=1:2
C(i)=xodvn(1)+((-1)^(i+1))*xodvn(2)
end
for i=1:2
D(i)=xodod(1)+((-1)^(i+1))*xodod(2)
end
for i=1:2
B(i)=((-1i)^(i-1))*B(i);
D(i)=((-1i)^(i-1))*D(i);
end
for i=1:4
if i<=2
G(i)=A(i)+B(i);
end
if i>2
G(i)=A(i-2)-B(i-2);
end

end
for i=1:4
if i<=2
H(i)=C(i)+D(i);
end
if i>2
H(i)=C(i-2)-D(i-2);
end
end
for i=1:4
H(i)=(exp(-1i*pi/4))^(i-1)*H(i);
end
for i=1:8
if i<=4
X(i)=G(i)+H(i);
end
if i>4
X(i)=G(i-4)-H(i-4);
end
end
X
Result:
Give the sequence=[1 2 3 4 4 3 2 1]
X=
Columns 1 through 3
20.0000

-5.8284 - 2.4142i

Columns 4 through 6
-0.1716 - 0.4142i

-0.1716 + 0.4142i

Columns 7 through 8
1

-5.8284 + 2.4142i

Give the sequence=[0 1 2 3 4 5 6 7]


X=
Columns 1 through 3
28.0000

-4.0000 + 9.6569i -4.0000 + 4.0000i

Columns 4 through 6

-4.0000 + 1.6569i -4.0000

-4.0000 - 1.6569i

Columns 7 through 8
-4.0000 - 4.0000i

-4.0000 - 9.6569i

Discussion:
The two results which are determined through matlab program are actually matched
with the result determined manually.

You might also like