# Why are these Fourier transform values not as expected?

We are being taught Fourier Transform in our EE course this semester and I have several questions about it. The answers do not need to be rigorous and mathematical, all I need is an intuitive 'feel' of the Fourier Transform. I may be completely wrong at certain points so feel free to point it out.

1. Is the FT of a continuous function $x(t)$ approximately equal to the DFT of the discreet-time version of the same function?
In other words, if
• $X(\omega)$ if the FT of $x(t)$
• $T$ is an array containing closely spaced values of time (for example [-10:0.001:10])
• $y$ is an array containing $x(t)$ $\forall$ $t\in T$
• $Y$ is an array containing the DFT of y
• $Y'$ contains values of $X(\omega)$ for corresponding $\omega$
Then is $Y \approx Y'$
2. Can someone please explain the result of the following code

t = [-10:0.001:10]
x = sin(t)
y = fft(x)
z = abs(real(y))


I expected z to be an array of real numbers containing a sharp peak as the FT of a function gives the spectrum of frequencies contained in the fourier series representation of the function. But it turned out that the maximum was 4.32 and the mean of all values of the array was 0.55, which does not seem to be what I expected.
Is there something wrong in the way I am interpreting the fourier transform? How do I need to proceed if I need to calculate the frequency spectrum of this function?

• try z = abs(y) to get the complete magnitude – alex.forencich Oct 15 '14 at 5:38
• Check out this answer to a very similar question. – Matt L. Oct 15 '14 at 7:33

1. Intuitively the DFT and FT are similar. As the other poster pointed out, the main difference is that sampling in the time domain is equivalent to repetition in the Frequency domain, so the DFT will have repeated spectra at multiples of the sample frequency.

2. Two problems here.

i) abs(real(y)) is incorrectly being used. You need the absolute value (or magnitude) of both the imaginary and real components ... abs(y).

ii) You're seeing the effect of spectral leakage because the DFT assumes a repetitive signal; i.e. the maths "assumes" the signal you applied is repeated infinitely. Your signal will have discontinuities in this case.

Try the following code:

t = [-10*pi:pi/10:9.9*pi]
x = sin(t)
y = fft(x)
z = abs(y)


You should see this:

• Thanks, that worked! I now understand the "spectral leakage" thing. But can you please elaborate on why should abs(y) be used. – Lakshay Garg Oct 15 '14 at 10:15
• because the magnitude of a complex number is the square root of the imaginary part squared plus the real part squared. You were excluding the imaginary part. – akellyirl Oct 15 '14 at 11:45
1. You're a bit confused here. It's quite simple to remember actually. If you sample in the time domain, the D(iscrete) FT that you obtain will be a periodical repetition of the FT of the original function. Conversely, if you have a periodical repetition of the signal in the time domain, the Fourier Series will be a sampling of the FT of the original signal.
Even nicer, there is an exact relationship between the sampling frequency in one domain and the period in the other domain.
$$\mathcal{F}\left[\sum\limits_k{x(kT)}\right] = \sum\limits_n{X\left(f+\dfrac{n}{T}\right)}$$ and viceversa.
DFT (as Digital) is a bit different, since it's a Discrete approximation of the FT of a discrete signal.

2. One thing is that you're FFTing (basically DFTing, see above) and therefore approximating the "real" Fourier transform of your signal. In order to obtain a perfect peak you would need to compute the Fourier series of a continuous, perfectly periodical (therefore theoretical) sinusoidal signal. You can't do it computationally I'm afraid, but perhaps Mathematica has some analytical way to operate with such things.

The FT of a continuous function x(t) is approximately "equal" to the DFT of the discreet-time version of the same function, if the sample interval is long enough (compared to the period of the domain function), and the sample rate is fast enough.

If, as in your example, the sample interval is not long enough (10 is only a bit more than 3 periods of your domain function), then the DFT will not be "equal" to the FT.

Your example result reflects the fact that your DFT is describing a signal which, outside the sample points, is different than the signal your FT is describing. If you give your DFT a signal which, outside the sample points, is exactly the same as the signal the FT is describing, you should get the "same" answer.

A DFT domain signal which is approximately the same as a FT domain signal has the characteristics: (1) a sample period which matches the signal period, or is very much larger than the signal period, AND, (2) has a sample rate which matches the signal period, or is very much faster than the signal period.

"same" and "equal" because they are different transforms, and in theory mean different things, but will give arithmetically equal results if scaled correctly.

Alternatively, "same" and "equal" because they already "same and equal" but give arithmetically different results because they are different in theory.

If you understand, the fact that you have arithmetically different values is not important: the transforms are just alternate ways of looking at the same data. If you do not understand, then you may use enough points so that you don't have to understand. EE's should understand: an Engineer can do with 64 points what any damn fool can do with 640 points. Play around with different sample intervals and rates to get an idea of the way a DFT represents a signal.