[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

05/09/2009 at 05:57PM PDT, ID: 24395379 | Points: 500
[x]
Attachment Details

FFT code issue

Asked by montu_12 in MatLab Programming Language

Hi guys,

I am having hard time to figure out the 8 point FFT algorithm, I am passing thie input array which is currect according to the requirement but my FFT algorithm is not working and not giving me right values

Please check my code and see - what am i doing wrong....

Please Help
Its urgent
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
x = 0:1:40;
t = 0:1:40;
 
phas1 = 0;
phas2 = (2*pi)*(1/8);
phas3 = (2*pi)*(2/8);
phas4 = (2*pi)*(3/8);    
phas5 = phas4;
 
i(1) = 0;
 
for i= 2:9
    x(i) = x(i - 1) + phas1;
end
 
for i = 10:17 
    x(i) = x(i - 1) + phas2;
end
 
for i = 18:25 
    x(i) = x(i - 1) + phas3;
end
 
for i = 26:33 
    x(i) = x(i - 1) + phas4;
end
 
for i = 34:41 
    x(i) = x(i - 1) + phas5;
end
 
 
for i = 1:41 
    x(i) = cos(x(i));
end
 
 
stem(t, x);
 
s = ones(1,8);
fft(s)
 
% Bit Reversal 
% To do Bit Reversal we need to Flip the array values     
 
temp = x(1);
x(1) = x(8);
x(8) = temp;
 
temp = x(2);
x(2) = x(7);
x(7) = temp;
 
temp = x(3);
x(3) = x(6);
x(6) = temp;
 
temp = x(4);
x(4) = x(5);
x(5) = temp;
 
% Bit Reversal End
 
%%%%%%%% STAGE 1 %%%%%%%%%
 
x(1) = x(1) - x(2);
x(5) = x(2) + x(1);
 
x(3) = x(3) - x(4);
x(7) = x(4) + x(3);
 
x(2) = x(5) - x(6);
x(6) = x(6) + x(5);
 
x(4) = x(7) - x(8);
x(8) = x(8) + x(7);
 
 
%%%%%%%% STAGE 2 %%%%%%%%%
w = -0.707;
 
 
x(1) = x(1) - x(3);
x(5) = x(2) - x(4);
 
x(3) = x(3) + x(1);
x(7) = (x(4)* w) + x(2);
 
x(2) = x(5) - x(7);
x(6) = x(6) - x(8);
 
x(4) = x(7) + x(5);
x(8) = (x(8) * w) + x(6);
 
%%%%%%%% Stage 3 %%%%%%%%
 
x(1) = x(1) - x(5);
x(5) = x(2) - x(6);
 
x(3) = x(3) - x(7);
x(7) = x(4) - x(8);
 
x(2) = x(5) + x(1);
x(6) = (x(6)*w)  + x(2);
 
x(4) = (x(7) * w* w) + x(3);
x(8) = (x(8)* w *w *w) + x(4);
 
 
 
x(1)
x(2)
x(3)
x(4)
x(5)
x(6)
x(7)
x(8)
 
Loading Advertisement...
 
[+][-]05/10/09 06:17 AM, ID: 24348248

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]05/10/09 04:33 PM, ID: 24350494

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625