Corrected separately complex number counting.
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
clear; % clears all previus values from memory
|
clear; % clears all previus values from memory
|
||||||
clc; % clear command window
|
clc; % clear command window
|
||||||
fs = 44100; % samplinf freq.
|
fs = 44100; % samplinf freq.
|
||||||
fftLength=512; % windowlength
|
fftLength=128; % windowlength
|
||||||
stage_num = log2(fftLength);
|
stage_num = log2(fftLength);
|
||||||
% signal frequencies
|
% signal frequencies
|
||||||
max = 2048 - 1 ;
|
max = 2048 - 1 ;
|
||||||
@@ -90,8 +90,11 @@ real_n = zeros(bits+1,fftLength);
|
|||||||
imag_n = zeros(bits+1,fftLength);
|
imag_n = zeros(bits+1,fftLength);
|
||||||
|
|
||||||
Wn = zeros(1,fftLength/2); % complex
|
Wn = zeros(1,fftLength/2); % complex
|
||||||
Wr = zeros(1,fftLength/2); % real
|
%Wr = zeros(1,fftLength/2); % real
|
||||||
Wi = zeros(1,fftLength/2); % imag
|
%Wi = zeros(1,fftLength/2); % imag
|
||||||
|
%
|
||||||
|
% Wr_sfi = zeros(1,fftLength/2);
|
||||||
|
% Wi_sfi = zeros(1,fftLength/2);
|
||||||
|
|
||||||
%% New stages
|
%% New stages
|
||||||
|
|
||||||
@@ -104,24 +107,29 @@ for st = 0 : stage_num;
|
|||||||
else st > 0;
|
else st > 0;
|
||||||
for n = 1 : fftLength/2;
|
for n = 1 : fftLength/2;
|
||||||
Wn(n) = exp(-j * (n-1) * 2 * pi/ 2^(st) );
|
Wn(n) = exp(-j * (n-1) * 2 * pi/ 2^(st) );
|
||||||
Wr(n) = real(Wn(n));
|
Wr(n) = real(Wn(n));%sfi(real(Wn(n)),16,15);%
|
||||||
Wi(n) = imag(Wn(n));
|
Wi(n) = imag(Wn(n));%sfi(imag(Wn(n)),16,15);%
|
||||||
end
|
end
|
||||||
for i = 1 : 2^st : fftLength;
|
for i = 1 : 2^st : fftLength;
|
||||||
for k = 0 : 2^(st-1)-1;
|
for k = 0 : 2^(st-1)-1;
|
||||||
% Even
|
% Even
|
||||||
stage(st+1,i+k) = stage(st,i+k) + Wn(k+1)*stage(st,i+k+2^(st-1));
|
stage(st+1,i+k) = stage(st,i+k) + Wn(k+1)*stage(st,i+k+2^(st-1));
|
||||||
real_n(st+1,i+k) = real_n(st,i+k) + Wn(k+1)*real_n(st,i+k+2^(st-1));
|
real_n(st+1,i+k) = real_n(st,i+k) + Wr(k+1)*real_n(st,i+k+2^(st-1)) - Wi(k+1)*imag_n(st,i+k+2^(st-1));
|
||||||
imag_n(st+1,i+k) = imag_n(st,i+k) + Wn(k+1)*imag_n(st,i+k+2^(st-1));
|
imag_n(st+1,i+k) = imag_n(st,i+k) + Wi(k+1)*real_n(st,i+k+2^(st-1)) + + Wr(k+1)*imag_n(st,i+k+2^(st-1));
|
||||||
% Odd
|
% Odd
|
||||||
stage(st+1,i+k+2^(st-1)) = stage(st,i+k) - Wn(k+1)*stage(st,i+k+2^(st-1));
|
stage(st+1,i+k+2^(st-1)) = stage(st,i+k) - Wn(k+1)*stage(st,i+k+2^(st-1));
|
||||||
real_n(st+1,i+k+2^(st-1)) = real_n(st,i+k) - Wn(k+1)*real_n(st,i+k+2^(st-1));
|
real_n(st+1,i+k+2^(st-1)) = real_n(st,i+k) - Wr(k+1)*real_n(st,i+k+2^(st-1)) + Wi(k+1)*imag_n(st,i+k+2^(st-1));
|
||||||
imag_n(st+1,i+k+2^(st-1)) = imag_n(st,i+k) - Wn(k+1)*imag_n(st,i+k+2^(st-1));
|
imag_n(st+1,i+k+2^(st-1)) = imag_n(st,i+k) - Wi(k+1)*real_n(st,i+k+2^(st-1)) - Wr(k+1)*imag_n(st,i+k+2^(st-1));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
% for n = 1 : fftLength/2;
|
||||||
|
% Wr_sfi(n) = sfi(real(Wn(n)),16,15);
|
||||||
|
% Wi_sfi(n) = sfi(imag(Wn(n)),16,15);
|
||||||
|
% end
|
||||||
|
|
||||||
%% Ploting out
|
%% Ploting out
|
||||||
% slowly plot result
|
% slowly plot result
|
||||||
figure(5)
|
figure(5)
|
||||||
|
|||||||
Reference in New Issue
Block a user