claudiocamera
Full Member level 4
- Joined
- Aug 19, 2005
- Messages
- 224
- Helped
- 27
- Reputation
- 54
- Reaction score
- 6
- Trophy points
- 1,298
- Location
- Salvador-BA-Brazil
- Activity points
- 4,282
decimation in frequency
Hi,
I am trying to develop a function in Matlab to calculate FFT using DIF RADIX 2. In order to test it , firstly I am working with a signal with length =8 x= [0 1 2 3 4 5 6 7]. Unfortunatelly it is not returning the correct result, I cant find what is wrong with the algorithm.
If somebody realise what is wrong in the code below, please let me know.
Thxs
% x= Imput data
x=[0 1 2 3 4 5 6 7];
% Length of imput data
N=length(x);
x; % Buffer x
% Twidle factor
WN=exp(-j*2*pi/N);
% FFT routine
passo=N/2;
for Ni = 1:est
h=2^(Ni-1);
v=N/h;
for m=0:v:N-1
for z = 1asso
xnew(z+m)=x(z+m)+x(z+passo+m);
xnew(z+passo+m)=x(z+m)-x(z+passo+m)*WN^((z-1)*h);
end
end
passo=passo/2;
x=xnew;
end
% bit reverse routine
xbr=zeros(1,N);
dec=[0:N-1];
bin=dec2bin(dec);
dec1=bin2dec(fliplr(bin))';
dec1=dec1+ones(1,N);
for i = 1:N;
xbr(i)=x(dec1(i));
end
Hi,
I am trying to develop a function in Matlab to calculate FFT using DIF RADIX 2. In order to test it , firstly I am working with a signal with length =8 x= [0 1 2 3 4 5 6 7]. Unfortunatelly it is not returning the correct result, I cant find what is wrong with the algorithm.
If somebody realise what is wrong in the code below, please let me know.
Thxs
% x= Imput data
x=[0 1 2 3 4 5 6 7];
% Length of imput data
N=length(x);
x; % Buffer x
% Twidle factor
WN=exp(-j*2*pi/N);
% FFT routine
passo=N/2;
for Ni = 1:est
h=2^(Ni-1);
v=N/h;
for m=0:v:N-1
for z = 1asso
xnew(z+m)=x(z+m)+x(z+passo+m);
xnew(z+passo+m)=x(z+m)-x(z+passo+m)*WN^((z-1)*h);
end
end
passo=passo/2;
x=xnew;
end
% bit reverse routine
xbr=zeros(1,N);
dec=[0:N-1];
bin=dec2bin(dec);
dec1=bin2dec(fliplr(bin))';
dec1=dec1+ones(1,N);
for i = 1:N;
xbr(i)=x(dec1(i));
end