Differences

This shows you the differences between two versions of the page.

tutorial:the_discrete_fourier_transformation_dft [2012/05/29 00:00]
Simon-Shlomo Poil [Background]
tutorial:the_discrete_fourier_transformation_dft [2014/12/04 11:45] (current)
Line 5: Line 5:

==== Goal of tutorial ==== ==== Goal of tutorial ====
-In this tutorial you will use Matlab to:+In this tutorial you will use Matlab ([[tutorial:getting_started_with_matlab|]]) to:
- Understand and apply the Fourier Transform (FT).   - Understand and apply the Fourier Transform (FT).
- Use the Fast Fourier Transform (FFT)   - Use the Fast Fourier Transform (FFT)
Line 11: Line 11:
- Learn to work with complex numbers and complex functions.   - Learn to work with complex numbers and complex functions.

+<note tip>You can run FFT analysis in the NBT toolbox ([[tutorial:download_and_install_nbt|]]) (using the Welch method).
+
+See
+
+[[tutorial:amplitude_in_classical_frequency_bands|]]
+
+or
+
+[[tutorial:power_spectra_wavelet_analysis_and_coherence|]]</note>

===== Background ===== ===== Background =====
Line 19: Line 28:
Once you have understood this simple exercise, you can easily invent a slightly more complicated example (longer signal and multiple frequency components) or intuitively accept that the idea also applies to longer signals.  Once you have understood this simple exercise, you can easily invent a slightly more complicated example (longer signal and multiple frequency components) or intuitively accept that the idea also applies to longer signals.

-As in the other tutorials, we ask you to type the commands instead of copying directly from the wiki, because part of learning Matlab and the content of the formulas introduced here is to get "hands-on experience"...!+As in the other tutorials, we ask you to type the commands instead of copying directly from this page, because part of learning Matlab and the content of the formulas introduced here is to get "hands-on experience"...!

Line 26: Line 35:
** Preparation for the tutorial ** ** Preparation for the tutorial **

-The commands on in this box ensure that the following exercise has all the necessary scripts and does not interfere with variables or graphics from previous exercises. If you come directly from another exercise it should be clear which commands you can skip.+The commands in this box ensure that the following exercise has all the necessary scripts and does not interfere with variables or graphics from previous exercises. If you come directly from another exercise it should be clear which commands you can skip.

Start MATLAB and find your current working directory using 'pwd'. Start MATLAB and find your current working directory using 'pwd'.
Line 98: Line 107:
phs = 90/360; % the phase of the wave.  phs = 90/360; % the phase of the wave.

- [wave] = SignalGenerator_sin(frq, len, Fs, phs); % Generate a sine wave.+ [wave] = signalgenerator_sin(frq, len, Fs, phs); % Generate a sine wave.
</code> </code>

Line 148: Line 157:
</note> </note>

-Note that in the summation over n = 0, 1, … N-1, the value of the basis function (e_k[n]) is computed ("sampled") at the same times 'n' as your recorded signal x[n] was sampled. +Note that in the summation over n = 0, 1, … N-1, the value of the basis function ($e_{k}[n]$) is computed ("sampled") at the same times 'n' as your recorded signal x[n] was sampled.

-Thus, the DFT formula basically states that the k’th frequency component is the sum of the element-by-element products of 'x' and 'e_k', which is the so-called inner product of the two vectors x = [x(0), x(1), … x(N-1)] and e_k = [e_k(0), e_k(1),… e_k(N-1)], i.e.,:+Thus, the DFT formula basically states that the k’th frequency component is the sum of the element-by-element products of 'x' and '$e_{k}$', which is the so-called inner product of the two vectors $x = [x(0), x(1), … x(N-1)]and$e_{k} = [e_{k}(0), e_{k}(1),… e_{k}(N-1)]$, i.e.,: -X[k] = [x(0)*e_k(0) x(1)*e_k(1) ... x(N-1)*e_k(N-1)]+$X[k] = [x(0)*e_{k}(0)   x(1)*e_{k}(1)   ... x(N-1)*e_{k}(N-1)]$-Because e_k is a unit-length vector, the inner product of x and e_k may be seen (somewhat abstractly…) as a **"projection of the data x onto the complex basis function e_k"**.+Because$e_{k}$is a unit-length vector, the inner product of x and$e_{k}$may be seen (somewhat abstractly…) as a **"projection of the data x onto the complex basis function**$e_{k}$**"**. -In order to directly apply the DFT formula to our 'x', we therefore compute the basis vectors ('e_k') corresponding to the value of the basis functions at times 'n' and our value of 'N' (use the "arrow-up key" to speed up typing):+In order to directly apply the DFT formula to our 'x', we therefore compute the basis vectors ('$e_{k}\$') corresponding to the value of the basis functions at times 'n' and our value of 'N' (use the "arrow-up key" to speed up typing):

<code> <code>
Line 276: Line 285:

<note>In the next section [[tutorial:fourier_transform_and_reconstruction_of_real_signals]], you will Fourier transform and reconstruct real broad-band neuronal data with oscillatory components.</note> <note>In the next section [[tutorial:fourier_transform_and_reconstruction_of_real_signals]], you will Fourier transform and reconstruct real broad-band neuronal data with oscillatory components.</note>
+
+<html>
+<!-- nbtwikibundbar -->