Difference between FFT and DFT spectrum! why ?!

3 ビュー (過去 30 日間)
Ali
Ali 2014 年 9 月 1 日
コメント済み: Ali 2014 年 9 月 5 日
Hi every body, can some one help me to understand the reason of difference between the spectrum of the DFT(raw formulas) and FFT which I have implemented via the following code? I am investigating the harmonics up to 9 KHZ for a signal with 50 hz basic frequency and the differences appear mostly in ranges higher than 6 KHz.
I have run this code on a set of samples with 10004 samples which is attached to this post .(just import the variables to matlab and run the code below )
for DFT I have used the formulas in yhe below link : DFT formula
CODE:
%%reading in the samples
wave; %%%a 10004 samples signal with basic frequency of 50 Hz which means 10 complete period of the fundametal wave
%%Normal FFT
wavefft1 = fft(wave);
L=size(wave,1)-1; % removing the mirror side of spectrum
MagSpec1 = abs(wavefft1(1:1801))/(L/2); %%removing the mirror side of the spectrum
% and ranging the domain
%%DFT implementation
f = 49.985004498650405; %%f = 10/(time(10004)-time(1)) we have used 10 because these samples consist of 10 periods of the signal with 50 Hz frequency
Sampling_Fequency = 50000;
N = size (wave,1)
ll = 0;
for k = 0: f/10:180*f;
cplx_val =0;
for x = 1:N
Teta = ((2*pi*k*x)/Sampling_Fequency);
cplx_val = cplx_val+(wave(x,1)*complex(cos(Teta),(-1*sin(Teta))));
end
ll = ll+1;
MagSpec2(ll,1) = (floor((abs(cplx_val)/(N/2))*10^6))/10^6; %%removing the mirror side of the spectrum
% and ranging the domain
end
%%drawing the caomparison plot
set(0,'DefaultFigureVisible','on');
figure;
x1 = (0:1800)*5;
plot(x1,MagSpec1,'r-');hold on;
plot(x1,MagSpec2,'g-');
legend('FFT Normal','DFT');
  2 件のコメント
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014 年 9 月 1 日
Ali you can attach your code and sample image here! It's probably easier for lazy ppl like me.
Ali
Ali 2014 年 9 月 1 日
thanks for your hint. I attached the files.

サインインしてコメントする。

採用された回答

Matt J
Matt J 2014 年 9 月 1 日
編集済み: Matt J 2014 年 9 月 1 日
omega=exp(-(2*pi/N)*(0:N-1));
j=sqrt(-1);
for k=N:-1:1
DFT(k) = ( omega.^(j*(k-1)) )*wave(:);
end
  1 件のコメント
Ali
Ali 2014 年 9 月 5 日
thanks a lot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by