# Discrete Fourier Transform (DFT) Help

I took
f(t) = SIN(10*t) +SIN(5*t)
and got this
f(0) = 0
f(1) = -1.5
f(2) = 0.4
f(3) = -0.3

now I tried to do the DFT
Fs = 4Hz
N = 4 samples
3
f[r] = Ʃ x[k]ε^(-j(2πkr/4)
k=0

f[r] = 0 -1.5ε^(-j(2πr/4) + 0.4ε^(-j(2π(2)r/4) -0.3ε^(-j(2π(3)r/4)
f = 0 - 1.5 + 0.4 - 0.3 = -1.4 // now that mean i have a frequency of 0 but I do not..
f = 0 + 1.5j -0.4 -0.3 = 1.5j -0.7
f = 0 +1.5 + 0.4 +0.3 = 2.2
f = 0 -1.5-0.4 +0.3j = -1.9 + 0.3j

ok so I think I am close to understand how to do a DFT but I know that is wrong because I do not have a 0Hz frequency nor do I have a 2Hz frequency
I have 5 and 10

jasonRF
Gold Member
I hope you realize that your signal has frequencies 10/(2*pi) and 5/(2*pi). Assuming t represents time in seconds, these correspond to about 1.6 and 0.8 Hz, and you are sampling at 1 Hz (you let t=0,1,2 and 3 seconds). If t has other units then scale accordingly. I did not check your arithmetic, but for this example you will need to understand aliasing, and what happens with signals whose frequencies are not exactly the centers of your frequency bins.

A simpler example would be to consider $f(t) = \exp\left( i \frac{\pi}{2} t \right)$ sampled at t=0,1,2 and 3. Here the frequency is 1/4 Hz and the sample rate is 1 Hz.

jason

jasonRF:

no I did not know that...
frequencies 10/(2*pi) and 5/(2*pi)
where did that come from ?

I thought it was F(t) = sin(10*t)

jasonRF
Gold Member
For a sinusoid, if $t$ is in seconds and the frequency $f$ is in Hz, then the function looks like $f(t) = \sin(2 \pi f t)$. Think about what it means. At time $t=1/f$ the argument of the sine is simply $2\pi$, which means you are at the time it takes for a single cycle of the function. So if the frequency is 5 Hz, at time 0.2 seconds you have gone through a complete cycle. In your case, you have two frequencies, $2 \pi f_1 = 10$ and $2\pi f_2 = 5$.

jason

Last edited:
ok I did that
F = 10 / 2π
f(t) = 10sin( F*2*PI * t)
for 0< T< 16
and
i got
0
-5.4402111088937
9.12945250727628
-9.88031624092862
7.45113160479349
-2.62374853703929
-3.04810621102217
7.73890681557889
-9.93888653923375
8.93996663600558
-5.06365641109759
-0.44242678085071
5.80611184212314
-9.30105950186762
9.80239659440312
-7.14876429629165
2.19425258379005

F = -4.01920962704459// this should be 0
F = -4.14537895434982 // this should be 0
F = -4.57274112337475// this should be 0
F = -5.49565172200391// this should be 0
F = -7.50172957187673// this should be 0
F = -12.8720176748774// this should be 0
F = -41.819518848926// this should be 0
F = 62.2685945081662// this should be 0
F = 32.2960964015296// this should be 0
F = 62.2685945081661// this should be 0
F = -41.8195188489261

why?
what I am doing wrong ?

UP date
ok now I am going this
for 0 < i <16
t1 = i / 120;
F(t) = Sin( 2 * PI* t1 );

0
0.0523359562429438
0.104528463267653
0.156434465040231
0.207911690817759
0.258819045102521
0.309016994374947
0.3583679495453
0.4067366430758
0.453990499739547
0.5
0.544639035015027
0.587785252292473
0.629320391049838
0.669130606358858
0.707106781186547
0.743144825477394
F = 5.94612377310945
F = -0.487400945100295
F = -0.401272266173451
F = -0.385629134617898
F = -0.38024247781543
F = -0.3778404948171
F = -0.376648333895417
F = -0.376075997767909

this seem to be working

I know that is the number of sample from the sin wave..
what do you all think?

ok I am not setting up the test sine wave right
can some one help me?

jasonRF
Gold Member
Have you tried the example I gave you?

yes
cry...

jasonRF
Gold Member
UP date
ok now I am going this
for 0 < i <16
t1 = i / 120;
F(t) = Sin( 2 * PI* t1 );

0
0.0523359562429438
0.104528463267653
0.156434465040231
0.207911690817759
0.258819045102521
0.309016994374947
0.3583679495453
0.4067366430758
0.453990499739547
0.5
0.544639035015027
0.587785252292473
0.629320391049838
0.669130606358858
0.707106781186547
0.743144825477394
F = 5.94612377310945
F = -0.487400945100295
F = -0.401272266173451
F = -0.385629134617898
F = -0.38024247781543
F = -0.3778404948171
F = -0.376648333895417
F = -0.376075997767909

this seem to be working

I know that is the number of sample from the sin wave..
what do you all think?
I'm curious what reading you have done on the DFT - have yuo looked at any books or web sites that explain the theory? Anyway, there are a couple of issues you need to understand about this current example of yours:

1) the DFT assumes that your signal is periodic, and the sequence that you give it is one period. So to understand the periodic signal you are analyzing, think about the sequence of numbers you give it, and then make copies of that sequence on both sides of your signal. In your case you have a 1 Hz signal sampled at 120 Hz (which is good, you are no longer doing an aliased example). However, you are only taking 17 samples, so you only have 17/120 of a sinusoid. If you think about making copies of it right an left, you are essentially giving the DFT a sawtooth kind of signal. The "edges" have lots of high frequency content. That is why the example I gave you I made sure that I gave you exactly one cycle, since that is the first case you should try as it is simple to understand.

2) Your 1 Hz signal is not centered on a DFT frequency bin. You need to learn what frequencies correspond to the bins in your DFT sequence. you have 17 samples at 120 Hz, for a total of 17/120 of a second of signal. Thus the frequencies associated with your sequence after the DFT are at 0, 120/17, 240/17, 360/17, etc. Hz. So your 1 Hz signal is not at the center of any bin, so you will see the sidelobes from the signal show up in all of the bins.

jason

$f(t) = \exp\left( i \frac{\pi}{2} t \right)$ sampled at t=0,1,2 and 3. Here the frequency is 1/4 Hz and the sample rate is 1 Hz.

jason
sorry I do not understand how this will work
F[t] =e^(i(pi/2) *t )

-1.81275621683602E-14
1
4.86454409739934E-16
-1
-1.12670560815237E-14
1
2.20476577533074E-14
-1
-4.40654999468715E-15
1
1.51871516664709E-14
-1
-2.59677533382546E-14
1
3.67483550100384E-14
-1
9.31446217898591E-15
1
1.46613949279784E-15
-1
-1.22467411645816E-14
1
2.30273428363653E-14
-1
-3.38079445081491E-14
1
-1.22548726808752E-14
-1
1.47427100909148E-15
1
9.30633066269226E-15
-1
-2.0086932334476E-14
1
3.08675340062597E-14
-1
1.51952831827645E-14
1
-4.41468151098079E-15
-1
-6.36592016080295E-15
1
1.71465218325867E-14
-1
-2.79271235043704E-14
1
3.87077251761542E-14
-1
7.3550920128701E-15

that is the real values

F = 1.36807096684163E-13
F = 2.84008927486923E-14
F = 5.27911048209262E-14
F = 4.80310236028458E-14
F = 1.55431223447522E-15
F = 3.3584246494911E-14
F = 6.85285161949878E-14
F = -6.48925357893404E-14
F = 1.76803016671556E-14
F = -5.88418203051333E-14
F = 3.06421554796543E-14
F = 2.39031017201796E-13
F = 1.12798659301916E-13
F = 8.7208018584306E-14
F = 1.91124893689221E-13
F = 3.05311331771918E-14
F = -4.56301663120939E-14
F = -1.06248343456627E-13
F = 1.40443212615082E-13
F = 4.72955008490317E-14
F = 2.97539770599542E-14
F = -1.77635683940025E-14
F = 3.75255382323303E-14
F = -3.14193115968919E-14
F = 5.17363929475323E-14
F = -5.19584375524573E-14
F = 2.33146835171283E-15
F = 1.18793863634892E-13
F = 1.90625293328139E-13
F = 2.18824958153618E-13
F = 3.02424751907893E-13
F = 5.91748872125208E-14
F = -1.30673249998381E-13
F = -3.17190718135407E-13
F = 6.16173778666962E-14
F = -1.13242748511766E-14
F = -6.0507154842071E-14
F = -1.15574216863479E-13
F = 4.61852778244065E-14
F = 6.58362253602718E-14
F = -1.60982338570648E-14
F = 8.63753513158372E-14
F = -7.88258347483861E-14
F = -1.8052226380405E-13
F = 1.53765888910584E-13
F = 3.61932706027801E-14
F = 2.04170014228566E-13
F = -2.51909604287448E-13
F = -4.49418280368263E-13
F = 6.46704911844154E-13
F = 200
F = -2.16604512104368E-13
F = 4.95936625100057E-13
F = 1.6198153929281E-13
F = -4.0911718457437E-13
F = 1.37889699658444E-13
F = 1.45772283133283E-13
F = 3.22075699443758E-13
F = -6.30606677987089E-14
F = -5.10924635932497E-13
F = -1.54654067330284E-13
F = 3.81250586656279E-13
F = 1.43551837084033E-13
F = 1.31783473023006E-13
F = 8.24895707296491E-14
F = -9.33697563709757E-14
F = 1.28008714739281E-13
F = 2.98872038229092E-13
F = 4.47641923528863E-13
F = -1.01918473660589E-13
F = -2.96429547574917E-13
F = 4.48530101948563E-14
F = -2.23709939461969E-13
F = -6.88338275267597E-14
F = 1.36890498936282E-13
F = -1.18127729820117E-13
F = -1.53654866608122E-13
F = -3.81916720471054E-14
F = -2.45692355349547E-13
F = -1.06248343456627E-13
F = -6.21724893790088E-14
F = -1.78634884662188E-13
F = -3.09752223870419E-14
F = 2.19824158875781E-14
F = 1.92956761679852E-13
F = -4.41868763800812E-14
F = -6.51312337396348E-13
F = 2.4008572907519E-13
F = -1.51878509768721E-13
F = -2.70561351101151E-13
F = -2.80608869474008E-13
F = 1.36779476633819E-13
F = -1.52183821100493E-13
F = 3.33122418538778E-13
F = -1.75470749042006E-13
F = 1.02140518265514E-14
F = 3.63598040564739E-14
F = -1.66380798027888E-13
F = -8.14764922196787E-14
F = 8.4760670704398E-13
F = -8.79020434999683E-14
F = 3.50657003433952E-13
F = 4.49876247365921E-13
F = -7.08877401223162E-14
F = 2.52353693497298E-13
F = -3.65818486613989E-14
F = -2.55684362571174E-13
F = -4.90607554581857E-13
F = 6.83064715900628E-14
F = 2.26763052779688E-13
F = 1.26526567001406E-12
F = -9.12048214729566E-14
F = 3.04201108747293E-14
F = -6.45039577307216E-14
F = 7.66220420445052E-13
F = -2.59903210064749E-13
F = 1.84741111297626E-13
F = 8.85957973650875E-14
F = -1.07136521876328E-13
F = 1.16573417585641E-14
F = 2.45914399954472E-13
F = -8.32556246166405E-13
F = -4.14446255092571E-13
F = -2.22488694134881E-13
F = -3.19411164184658E-13
F = -1.58761892521397E-13
F = 5.71875879984418E-13
F = 1.91846538655227E-13
F = 1.36890498936282E-13
F = 5.69544411632705E-14
F = 3.3850700020821E-13
F = -2.74780198594726E-13
F = -3.20743431814208E-13
F = -2.99760216648792E-14
F = -8.61866134016509E-13
F = -1.38888900380607E-13
F = 4.48863168855951E-13
F = 9.24815779512755E-14
F = 2.30149233004795E-13
F = 3.80473430539041E-13
F = -6.97220059464598E-14
F = 5.11812814352197E-14
F = -2.21045404202869E-13
F = -1.18571819029967E-13
F = 6.96109836439973E-13
F = -6.48370246381091E-14
F = -5.03042052457658E-13
F = 9.75886038645513E-14
F = -7.54951656745106E-15
F = -1.47160061914064E-12
F = 0
F = 2.50910403565285E-14
F = 7.00550728538474E-14
F = -2.27928786955545E-13
F = -4.10782519111308E-14
F = -1.20237153566904E-13
F = -2.72115663335626E-13
F = -6.46371844936766E-13
F = 1.15685239165941E-13
F = 2.25375273998907E-14
F = -4.33320046511199E-13
F = 2.93098878501041E-14
F = -3.75255382323303E-14
F = -2.29150032282632E-13
F = -4.18332035678759E-13
F = -2.61457522299224E-13
F = 2.47690756793872E-13
F = 1.09579012530503E-13
F = -3.79918319026729E-13
F = 4.40203429263875E-13
F = 6.83897383169096E-14
F = 1.11022302462516E-13
F = 4.27435864480685E-13
F = -2.08721928629529E-13
F = 1.23345778035855E-13
F = 6.13953332617712E-14
F = 4.29656310529936E-14
F = -1.10389475338479E-12
F = -9.68114477473137E-14
F = -1.32227562232856E-13
F = -1.77635683940025E-15
F = 3.12860848339369E-13
F = -3.75477426928228E-13
F = 1.63247193540883E-12
F = 6.49480469405717E-14
F = 3.54771767518969E-13
F = 3.76032538440541E-13
F = -1.13242748511766E-14
F = 6.16173778666962E-15
F = -1.31228361510694E-13
F = -3.23574500527002E-13
F = -1.54304347077527E-12
F = -4.27741175812457E-13
F = 1.16046061648944E-13
F = 2.95208302247829E-13
F = -1.34670052887031E-13
F = 5.89972515285808E-13
F = 1.46521683674905E-13
F = -1.51365031619832E-13
F = 1.84852133600089E-14
F = 3.76647226862231E-14
F = -2.88866153219658E-13
F = 3.81666920290513E-13
F = 1.99007477164059E-13
F = 9.29090138157562E-13
F = -1.09043329921121E-12
F = 1.57956980828544E-13
F = -9.55346912689947E-14
F = 7.65443264327814E-13
F = 1.5093482019779E-13
F = -4.54081217071689E-14
F = 2.85771406538515E-13
F = 1.09079412169422E-13
F = -4.34541291838286E-13
F = 1.58040247555391E-13
F = 4.43367564884056E-13
F = 2.61513033450456E-13
F = 4.32098801184111E-13
F = 2.98872038229092E-13
F = -7.56728013584507E-13
F = -2.61235477694299E-13
F = -1.45894407665992E-12
F = -3.30069305221059E-13
F = 8.59978754874646E-13
F = 4.59632332194815E-14
F = 7.88702436693711E-13
F = -4.10671496808845E-13
F = 1.7874590696465E-14
F = 1.52544643583497E-13
F = 4.78173056706055E-13
F = -2.09388062444305E-13
F = -2.88324919495153E-13
F = -1.72528658026749E-13
F = -1.11255449297687E-12
F = 7.55728812862344E-13
F = -2.77555756156289E-14
F = 1.98285832198053E-13
F = 1.98729921407903E-13
F = -3.21631610233908E-13
F = 4.47974990436251E-13
F = 8.95283847057726E-13
F = 5.35904653986563E-13
F = -1.49769086021934E-13
F = 4.16000567327046E-13
F = 1.77224901420914E-12
F = 4.20330437123084E-13
F = 6.53033183084517E-13
F = -3.26294546937334E-13
F = 1.65001345919791E-12
F = 3.96871424612755E-12
F = 200
F = 1.93145499594038E-12
F = 1.42263978375468E-12
F = 7.18758386142326E-13
F = 4.06341627012807E-13
F = 6.45261621912141E-13
F = -1.0866862965031E-12
F = -1.46882506157908E-12
F = -6.86117829218347E-14
F = -3.52717854923412E-13
F = -6.33049168641264E-13
F = -1.21203047598328E-12
F = -1.30673249998381E-13
F = -3.06421554796543E-14
F = 2.65121258280487E-13
F = 1.98396854500515E-13
F = 2.80109269112927E-13
F = -5.36348743196413E-13
F = 9.84878845144976E-13
F = 1.81743509131138E-13
F = -1.2081446953971E-12
F = -7.90256748928186E-13
F = -3.89022147828655E-13
F = 7.86037901434611E-14
F = -2.97428748297079E-13
F = -2.46058728947673E-12
F = -3.22519788653608E-13
F = -7.60946861078082E-13
F = -6.7257310831792E-13
F = 1.5780710072022E-12
F = -2.3214763444912E-13
F = 3.81916720471054E-13
F = -1.01030295240889E-14
F = 2.37032615757471E-13
F = -7.2908346027134E-13
F = 2.53075338463304E-13
F = -2.08055794814754E-13
F = -1.4477308241112E-13
F = -1.10744746706359E-13
F = -1.22019061521428E-12
F = 4.62130334000221E-13
F = -5.55555601522428E-13
F = 4.83002526863174E-13
F = -1.04877218021215E-12
F = 6.6044392177389E-13
F = -3.43419737092177E-13
F = -7.72437669382953E-14
F = 1.1671219546372E-13
F = 2.63858379589976E-13
F = -3.28966021090338E-13
F = 5.57025969403699E-13
F = 4.40904257548169E-13
F = 7.31151250654705E-13
F = 2.44512743385883E-13
F = -6.40265618301328E-13
F = 3.16136006262013E-13
F = -5.3002047195605E-13
F = -3.58907348285697E-13
F = 5.732636587652E-13
F = 8.79907258166668E-13
F = 8.48099368511157E-13
F = -8.76521077941561E-14
F = 8.09907696464052E-14
F = -1.1785017406396E-13
F = 5.14976949972379E-13
F = -1.5931700403371E-13
F = -1.52916568296746E-12
F = 5.27355936696949E-14
F = 3.10751424592581E-13
F = 1.73416836446449E-13
F = -6.29496454962464E-14
F = -1.28341781646668E-13
F = -2.92654789291191E-13
F = 5.68767255515468E-13
F = -3.78808096002103E-13
F = 4.17887946468909E-13
F = 3.45279360658424E-13
F = 1.53466128693935E-12
F = 5.45674616603264E-13
F = -2.24487095579207E-13
F = 2.02948768901479E-13
F = -3.68260977268164E-13
F = 5.79425396551869E-13
F = 3.1641356201817E-13
F = -3.574918139293E-14
F = -1.79412040779425E-13
F = 3.86135567964629E-13
F = 9.31255073055581E-13
F = -1.28752564165779E-12
F = -2.07056594092592E-13
F = -5.75872682873069E-13
F = -3.87800902501567E-13
F = 4.75064432237104E-13
F = -6.26609875098438E-13
F = -9.40136857252583E-13
F = 3.43391981516561E-13
F = -4.90607554581857E-13
F = -1.20681242776755E-13
F = 2.19158025061006E-13
F = -5.10702591327572E-13
F = 0
F = -7.58282325818982E-14
F = -6.05848704537948E-13
F = 4.17998968771371E-13
F = -9.38582545018107E-13
F = 1.08957287636713E-12
F = -2.90878432451791E-14
F = 1.6198153929281E-12
F = -1.47548639972683E-13
F = -4.25770529943748E-13
F = 8.59423643362334E-13
F = 8.31668067746705E-13
F = 1.37312383685639E-12
F = -4.07895939247283E-13
F = -6.16284800969424E-13
F = 1.05349062806681E-12
F = -6.86783963033122E-13
F = 9.28590537796481E-13
F = 2.23376872554581E-13
F = -8.86735129768113E-13
F = 4.81836792687318E-13
F = -7.4362738189393E-13
F = 1.73483449827927E-12
F = 6.31716901011714E-13
F = -5.01154673315796E-13
F = -5.38680211548126E-13
F = -1.1785017406396E-12
F = -7.73936470466197E-13
F = -1.38111744263369E-13
F = 1.7608137170555E-13
F = -1.10467190950203E-12
F = -6.66133814775094E-16
F = -5.37569988523501E-13
F = 2.25708340906294E-13
F = -2.359834549992E-12
F = 3.96904731303493E-13
F = 1.85518267414864E-13
F = 2.4980018054066E-13
F = 2.35261810033194E-12
F = -1.00192076857297E-12
F = -1.79800618838044E-12
F = -3.80973030900122E-13
F = -8.97920626741211E-13
F = -8.53206394424433E-14
F = -5.9643956440425E-13
F = 2.65731880944031E-13
F = -6.432354648922E-13
F = -6.23417983902641E-13
F = 4.21454537935517E-13
F = -6.78498923711857E-13
F = -6.21437851264922E-14
F = -2.34454122782779E-12
F = 8.30252533390308E-13
F = -9.10410635768244E-13
F = 5.45535838725186E-13
F = -4.17527123985906E-13
F = -2.38142838782096E-14
F = 8.9767082656067E-13
F = 4.62824223390612E-13
F = 1.52211576676109E-13
F = 2.18769447002387E-13
F = -1.90070181815827E-12
F = 3.14581694027538E-13
F = 4.70290473231216E-13
F = 7.04214464519737E-13
F = 9.47852907273727E-13
F = -1.67532654415936E-13
F = 2.00506278247303E-13
F = 1.80711001718237E-12
F = 8.53650483634283E-13
F = -2.15161222172355E-12
F = -7.13873404833976E-14
F = 1.27253763082535E-12
F = 3.52051721108637E-13
F = -6.40598685208715E-13
F = -5.33351141029925E-13
F = 2.28572716309827E-12
F = 3.49720252756924E-14
F = 5.46229728115577E-13
F = 1.00475183728577E-13
F = 1.25544019624613E-12
F = -1.25666144157321E-12
F = 3.13971071363994E-12
F = -3.82360809680904E-13
F = 2.316147273973E-12
F = 2.87547763377916E-14
F = 1.42807987657534E-12
F = 4.0600856010542E-13
F = -3.6981528950264E-13
F = 1.12798659301916E-13
F = -9.61897228535236E-13
F = -8.52762305214583E-13
F = 2.28039809258007E-12
F = 4.57978099888123E-12
F = -8.17124146124115E-14
F = 9.43245481721533E-13
F = 1.12410081243297E-12
F = 3.04833935871329E-12
F = 9.73665592596262E-13
F = -2.59003929414803E-12
F = 200
F = 2.36322073021711E-12
F = -2.9597435613482E-12
F = -4.94160268260657E-13
F = -1.77657888400518E-12
F = -1.26565424807268E-13
F = -1.42674760894579E-12
F = 4.76507722169117E-13
F = 2.8199664825479E-13
F = 1.07469588783715E-13
F = 1.48636658536816E-12
F = -5.88418203051333E-14
F = -1.02140518265514E-14
F = -1.79856129989275E-13
F = 3.77697872977478E-13
F = -2.35134134385362E-12
F = -1.18127729820117E-13
F = 3.92241794600068E-13
F = -1.8952617253376E-12
F = -1.75970349403087E-13
F = -2.05169214950729E-13
F = -2.18158824338843E-13
F = 1.79967152291738E-13
F = 3.72368802459278E-13
F = 3.23741033980696E-13
F = 3.67506025611419E-12
F = 7.37854222165879E-13
F = 4.37871960912162E-13
F = -4.61852778244065E-13
F = -8.43991543320044E-13
F = 1.27942101357803E-12
F = -3.98570065840431E-13
F = -4.54414283979077E-13
F = 3.17412762740332E-13
F = -5.94524429686771E-14
F = 4.57356374994333E-13
F = -1.94372296036249E-12
F = -1.05615516332591E-12
F = 2.31481500634345E-14
F = -7.03326286100037E-13
F = -1.72967196121476E-12
F = 2.93653990013354E-14
F = -3.07004421884471E-13
F = -9.1621155107191E-13
F = -6.20420381736153E-13
F = 1.35241817744713E-12
F = 7.54896145593875E-13
F = 1.81643589058922E-12
F = 2.39711028804379E-13
F = 9.53993828378685E-13
F = -8.47073631940823E-13
F = -2.40805986262416E-12
F = 6.11510841963536E-13
F = 7.56311679950272E-13
F = -8.37246938445446E-13
F = -2.2154500456395E-13
F = 8.24146306754869E-13
F = 1.37304057012955E-12
F = 5.07843767039162E-13
F = 2.62234678416462E-13
F = -7.7454709312974E-13
F = -3.02535774210355E-13
F = -1.0547118733939E-13
F = 6.41930952838266E-13
F = 2.66453525910038E-15
F = -8.1690210151919E-13
F = 2.38087327630865E-13
F = -1.81188397618826E-12
F = 1.16362475210963E-12
F = -2.2903900998017E-13
F = 2.18491891246231E-13
F = -6.75015598972095E-13
F = -2.41806574763359E-13
F = 1.98285832198053E-13
F = 1.01640917904433E-12
F = 1.75492953502498E-12
F = -3.52384788016025E-13
F = -1.60949031879909E-12
F = -4.30766533554561E-13
F = -1.93178806284777E-13
F = 4.89164264649844E-13
F = -5.11146680537422E-13
F = 6.96109836439973E-13
F = -1.10833564548329E-12
F = -1.42208467224236E-12
F = 6.96331881044898E-13
F = -1.75415237890775E-14
F = -3.01980662698043E-14
F = 5.21804821573824E-14
F = -5.43676215158939E-13
F = 3.39261951864955E-12
F = -3.46278561380586E-13
F = 2.76156875145261E-12
F = 1.86628490439489E-13
F = 8.80961970040062E-13
F = -2.71105360383217E-12
F = 1.14319664845652E-12
F = -5.66546809466217E-13
F = -1.249889081123E-12
F = -3.22264437357944E-12
F = 0
F = 3.49387185849537E-13
F = 6.92668145063635E-13
F = 1.80100379054693E-12
F = 4.70068428626291E-13
F = -8.77076189453874E-14
F = -9.76996261670138E-14
F = -1.65512048511118E-12
F = 2.44138043115072E-13
F = -5.63771251904654E-13
F = 2.57349697108111E-13
F = -1.59983137848485E-12
F = 6.65023591750469E-14
F = -6.02629057766535E-13
F = -8.22675261247241E-14
F = -7.04214464519737E-13
F = 3.46833672892899E-13
F = 1.42885703269258E-13
F = 9.51461132103759E-13
F = 8.70081784398735E-13
F = 1.948885497427E-12
F = -2.00173211339916E-13
F = -4.86166662483356E-12
F = 9.63673585374636E-14
F = 5.72986103009043E-13
F = 1.37834188507213E-12
F = -2.89768209427166E-14
F = -5.78248560145767E-12
F = 2.73003841755326E-13
F = 1.48758783069525E-12
F = 5.82756065625745E-13
F = -1.57684976187511E-12
F = 1.65867319878998E-13
F = -5.84199355557757E-13
F = 2.59675614344701E-12
F = 1.87683202312883E-13
F = 1.48542289579723E-12
F = -3.25295346215171E-13
F = -1.55497836828999E-12
F = -4.93993734806963E-13
F = 2.60624855030756E-13
F = -1.49635859258979E-12
F = -4.96466756594316E-12
F = 1.94691485155829E-12
F = -9.60065360544604E-13
F = 1.53613233244698E-12
F = 6.28969099025767E-13
F = 1.83275616905121E-12
F = 6.50438036764456E-13
F = 1.29060651055113E-12
F = -1.2525243700285E-12
F = -3.3435060275977E-13
F = -1.93949023508111E-12
F = -3.11098369287777E-13
F = 6.23445739478257E-13
F = 8.96699381414123E-13
F = 1.3725964809197E-12
F = -2.96532243204695E-12
F = -5.88029624992714E-13
F = -1.72806213782906E-13
F = 4.876654635666E-13
F = 8.70581384759817E-13
F = -2.59342547437313E-12
F = 8.10462807976364E-14
F = -4.51305659510126E-13
F = -9.289791158551E-13
F = 2.01755279150007E-12
F = 5.89306381471033E-13
F = -1.01529895601971E-12
F = 1.23201449042654E-12
F = -3.25406368517633E-13
F = 2.28483898467857E-13
F = -4.03899136358632E-13
F = 5.17130782640152E-12
F = 5.66768854071142E-13
F = 5.23359133808299E-13
F = -3.79363207514416E-13
F = -4.49418280368263E-13
F = 1.48459022852876E-12
F = 9.51017042893909E-13
F = 9.89319737243477E-13
F = 7.64943663966733E-13
F = 4.00457444982294E-13
F = 2.93876034618279E-13
F = -4.49862369578113E-13
F = 5.01720887058354E-12
F = 1.09978692819368E-12
F = -2.71227484915926E-13
F = 1.32771571514922E-12
F = 4.50306458787963E-13
F = 1.13653531030877E-12
F = -4.31099600461948E-13
F = 2.05391259555654E-12
F = -5.91748872125208E-13
F = 1.7705836796722E-12
F = 3.34732241924485E-13
F = 2.28572716309827E-12
F = 5.77138337121141E-12
F = 3.78985731686043E-12
F = 3.54627438525768E-12
F = 200

F = 200

F and F both have none 0s in them

rbj
1) the DFT assumes that your signal is periodic, and the sequence that you give it is one period. So to understand the periodic signal you are analyzing, think about the sequence of numbers you give it, and then make copies of that sequence on both sides of your signal.
boy am i glad to read someone else say this (without consequence). i get all bloodied-up on the comp.dsp newsgroup when i push this (clear, IMO) fact. they call me a thought-fascist for insisting on that fact.

the language i might use (because some people object to my anthropomorphizing regarding the word "assumes", since the DFT is not a thinking being) is that the DFT periodically extends the finite sequence passed to it.

jasonRF
Gold Member
I like your language - after posting I thought about editing to add a link to some periodic extension page somewhere, but got too lazy.

jasonRF
Gold Member
sorry I do not understand how this will work
F[t] =e^(i(pi/2) *t )

-1.81275621683602E-14
F = 200

F = 200

F and F both have none 0s in them
No need to actually print 100s of lines of numbers! Anyway, I guess I should have specified that I was using $i = \sqrt{-1}$. Also, I meant to evaluate it at only 4 points, t = 0,1,2 and 3. This was to be in line with your first example that had only 4 points, only the DFT is particularly simple.

so what is wrong with my DFT ?

public void DFT()
{
int N2 = N-1;
for (int F3 = 0; F3 < R; F3++)
{
for (int K = 0; K <= N2; K++)
{
F[F3] = F[F3] + (Complex)DSP.ElementAt(K) * Complex.Exp(-Complex.ImaginaryOne * (Math.PI * 2 * F3 * K) / N);// Complex.FromPolarCoordinates(1, ((Math.PI * 2 * F3 *K) / N));
}

}
}

jasonRF
Gold Member
I didn't say there was anything wrong with your DFT. I do think that you do not yet properly understand how the DFT works and what you should expect the output to look like for your example inputs. Note that the DFT typically takes N numbers and gives you back a different N numbers, so in the example I gave you the four numbers are
$$\begin{eqnarray} f(0) & = & 1 \\ f(1) & = & i \\ f(2) & = & -1 \\ f(3) & = & -i. \end{eqnarray}$$
Put that into your DFT and see what four numbers come out. The answer should be very simple.

jason

EDIT: in my equations above, I am using $i = \sqrt{-1}$.

Last edited: