Hi I had made a fft c program and it is working perfectly for discrete values. I have also checked it on MATLAB and quite sure that the program is correct. However I have two doubts. I inputted the samples of a sine wave of 1000 Hz with a sampling frequency 4000Hz. For a simple 16 point FFT I got two peaks one at x[4] and other at x[12]. Now shouldn't a simple sine wave show just one peak at 1000Hz. Is it that the values I get are centered along the imaginary axis. I am not able to understand where the frequency samples after doing fft actually lie in the spectrum. Please help me sorting this fundamental problem. I hope many of you know the answer. Thanks Aarul Jain

# Why two peaks in fft of sine wave

Started by ●July 12, 2003

Posted by ●July 12, 2003

"Aarul Jain" <aaruljain@yahoo.com> wrote in message news:207dbed8.0307120915.2d27d326@posting.google.com...> Hi > > I had made a fft c program and it is working perfectly for discrete > values. I have also checked it on MATLAB and quite sure that the > program is correct. > > However I have two doubts. > > I inputted the samples of a sine wave of 1000 Hz with a sampling > frequency 4000Hz. For a simple 16 point FFT I got two peaks one at > x[4] and other at x[12]. Now shouldn't a simple sine wave show just > one peak at 1000Hz. > > Is it that the values I get are centered along the imaginary axis. I > am not able to understand where the frequency samples after doing fft > actually lie in the spectrum. > > Please help me sorting this fundamental problem. I hope many of you > know the answer.Congratulations, it appears to be working properly! The FFT generates coefficients for complex exponentials. To get a sine, you need the sum of two complex exponentials - one at positive frequency and one at negative frequency. The FFT generates a single replica of a periodic spectrum. So you can think of the result as being plotted on a circular axis that repeats at x[0]=x[16]. The positive frequency component shows up 4 above x[0] or x[4] The negative frequency shows up 4 below x[16] or x[12]. Since the time function is real, the even part will transform to an even real function in frequency and the odd part will transform to an odd imaginary part in frequency. So, if the input was really sin(k*t) then you should have an odd, imaginary output. If the value at x[4] is j0.5 then the value at x[12] would be -j0.5. So, you really only need to know the N/2 values from x[0] to x[7] to know the whole thing. But, most FFTs allow complex inputs and provide the full N outputs. Fred

Posted by ●July 12, 2003

Thanks for your good help. Regards Aarul Jain "Fred Marshall" <fmarshallx@remove_the_x.acm.org> wrote in message news:<2IYPa.2572$Jk5.1759312@feed2.centurytel.net>...> "Aarul Jain" <aaruljain@yahoo.com> wrote in message > news:207dbed8.0307120915.2d27d326@posting.google.com... > > Hi > > > > I had made a fft c program and it is working perfectly for discrete > > values. I have also checked it on MATLAB and quite sure that the > > program is correct. > > > > However I have two doubts. > > > > I inputted the samples of a sine wave of 1000 Hz with a sampling > > frequency 4000Hz. For a simple 16 point FFT I got two peaks one at > > x[4] and other at x[12]. Now shouldn't a simple sine wave show just > > one peak at 1000Hz. > > > > Is it that the values I get are centered along the imaginary axis. I > > am not able to understand where the frequency samples after doing fft > > actually lie in the spectrum. > > > > Please help me sorting this fundamental problem. I hope many of you > > know the answer. > > Congratulations, it appears to be working properly! > The FFT generates coefficients for complex exponentials. > To get a sine, you need the sum of two complex exponentials - one at > positive frequency and one at negative frequency. > The FFT generates a single replica of a periodic spectrum. So you can think > of the result as being plotted on a circular axis that repeats at > x[0]=x[16]. > The positive frequency component shows up 4 above x[0] or x[4] > The negative frequency shows up 4 below x[16] or x[12]. > > Since the time function is real, the even part will transform to an even > real function in frequency and the odd part will transform to an odd > imaginary part in frequency. > So, if the input was really sin(k*t) then you should have an odd, imaginary > output. > If the value at x[4] is j0.5 then the value at x[12] would be -j0.5. So, > you really only need to know the N/2 values from x[0] to x[7] to know the > whole thing. But, most FFTs allow complex inputs and provide the full N > outputs. > > Fred