DFT example

  • Thread starter btb4198
  • Start date
  • #1
431
5
ok this is the best example i could find of DFT
http://faculty.ksu.edu.sa/ghulam/Documents/CEN352/DSP_CEN352_ch4_DFT.pdf

example 1)
this is what I am trying to do...
however it did not work for the guy...

f[1] should be the only one with an value
but it was a j0.5 and he got that for ever N-3..
why?

DFT should only return the frequency of the signal right???
so it should only return 1...
so why did it not work?
is he doing someone wrong in Example one ?
 

Answers and Replies

  • #2
meBigGuy
Gold Member
2,323
405
The spectrum repeats (aliases) about the sample rate. The basic DFT is from -2 to +2 and has a value in the +1 and -1 bins. If you only look at the -2,-1,0,+1,+2 bins you see what you'd expect.

His first example was pretty clean.
 
  • #3
431
5
ok I get what you are saying however I do not understand the " You wee what you'd expect" .

Wiki " In mathematics, the discrete Fourier transform (DFT) converts a finite list of equally spaced samples of a function into the list of coefficients of a finite combination of complex sinusoids, ordered by their frequencies, that has those same sample values. It can be said to convert the sampled function from its original domain (often time or position along a line) to the frequency domain."

so I would expect to see f[1] having a coefficients with a right number and the other to be 0.

ok I am very new to this. so what am I missing ?

also he has f[r] = 1/N Ʃ x(k) e^((-j2πfK)/n) for example 1 but for example 2 he does not have the 1/N.. when do you need the 1/N part?
 
  • #4
meBigGuy
Gold Member
2,323
405
The 1/N part is always confusing. You sometimes need to normalize. I can't easily explain it. Remember how you got 16 on a 16 sample sine wave? The 1/N would have made it 1. Some derivations use 1/sqrtN on both DFT and IDFT, some use 1/N on DFT, maybe some do 1/N on IDFT. A DSP expert could explain it better. It is just a scaling factor.

This example has both positive and negative frequency, so there is energy in both the +1 and -1 bins. (it reflects around 0)

I really reccommend watching some lectures on DSP that address the fundamentals of discrete signals.
 
  • #5
431
5
what happened if you add two signals with the same frequency together ?
 
  • #6
KHMOU YOUSSEF
If you add two signals with same frequency f1 ,Y[t]=A1*sin(2*pi*f1*t)+A2*sin(2*pi*f1*t) then when you compute the DFT, you get the max of the spectrum as the sum of theirs amplitudes A1+A2 at frequency f1 such f1 in [0, Fs] .
 
  • #7
431
5
If you add two signals with same frequency f1 ,Y[t]=A1*sin(2*pi*f1*t)+A2*sin(2*pi*f1*t) then when you compute the DFT, you get the max of the spectrum as the sum of theirs amplitudes A1+A2 at frequency f1 such f1 in [0, Fs] .
could you do the math and post it ?
because I am really starting to think that the DFT does not work..
I have see many examples online and none return the right frequency
 
  • #8
KHMOU YOUSSEF
what software are you using, ? here is an example using Matrix Laboratory :

Fs=80;
f=35;
t=(0:1/Fs:2-1/Fs);
a1=2;
a2=5;
y=a1*real(exp(j*2*pi*f*t))+a2*real(exp(j*2*pi*f*t));
n=length(y);
fy=fft(y,n)*2/n;
freq=(0:n-1)*Fs/n;
plot(freq(1:end/2), abs(fy(1:end/2)))
 
  • #9
431
5
I am write my on code in c# and I am going it by hand

so this is from math lab
x[n] = {1 –1 1 –1}

>> x = [1 -1 1 -1];
>> X = fft(x)
*
X =
*
0 0 4 0

*
4 0 0 0

but that is Wrong!!!
Math lab is wrong!!

I did it by hand I got this
i used
3
F[r] = Ʃ F[K]ε ^(-j 2πKr)/N
K=0
F[0] = 1 -1 +1 -1 = 0
F[1] = 1 + j +1 - J = 2
F[2] = 1 -1 -1 -1 = -2
f[3] = 1 +j +1 - j = 2
I do not understand
what is wrong with math lab ???

what it math lab doing ?
 
  • #10
431
5
I do not have Matrix Laboratory
can you do it by hand and post it that way?
 

Related Threads on DFT example

  • Last Post
Replies
5
Views
5K
  • Last Post
Replies
5
Views
10K
Replies
1
Views
8K
  • Last Post
2
Replies
29
Views
5K
  • Last Post
Replies
1
Views
6K
Replies
18
Views
5K
Replies
4
Views
2K
Replies
2
Views
560
  • Last Post
Replies
3
Views
14K
Replies
2
Views
565
Top