# A Pedagogical Tool for Fourier Transforms 4

Posted by **Loren Shure**,

I recently attended the DSP Workshop sponsored by the IEEE Signal Processing Society. It focues on both signal processing **and** signal processing education. I spoke to a lot of the attendees. Some of the professors and instructors mentioned how important
it is to teach the basics solidly first, before going into more depth. If the students don't get the fundamentals, then going
further doesn't help.

### Contents

### Pedagogical Tool - dftmtx

With that context, I asked how they teach Fourier transforms, especially once they go from the analog domain to the digital.
It turns out that most of them were unaware of some of the tools in Signal Processing Toolbox, such as `dftmtx`.

Here's the help.

```
h = help('dftmtx');
disp(h(1:744))
```

DFTMTX Discrete Fourier transform matrix. DFTMTX(N) is the N-by-N complex matrix of values around the unit-circle whose inner product with a column vector of length N yields the discrete Fourier transform of the vector. If X is a column vector of length N, then DFTMTX(N)*X yields the same result as FFT(X); however, FFT(X) is more efficient. The inverse discrete Fourier transform matrix is CONJ(DFTMTX(N))/N. An interesting example is D = dftmtx(4) which returns D = [1 1 1 1 1 -i -1 i 1 -1 1 -1 1 i -1 -i] which illustrates why no multiplications are necessary for 4-point DFTs. See also FFT and IFFT.

The help also mentions `fft`, the discrete Fourier transform, computed with a fast Fourier transform (fft) algorithm. With the information given for `dftmtx`, let's compare results with those of `fft`.

### More on dftmtx

On further inspection, you may notice that there are comments in the file outlining the calculation. As an aside, the computation
is actually done using the function `fft` in MATLAB.

Here's a brief description of the non-|fft| algorithm. Basically calculate frequencies on the unit circle and multiply by
`sqrt(-1)` (`w`). Multiply these by integral steps for the number of points in the transform (`w*x`). And then calculate all the `sin` and `cos` terms using `exp`.

Explicitly, the calculation is:

f = 2*pi/n; % Angular increment. w = (0:f:2*pi-f/2).' * i; % Column. x = 0:n-1; % Row. D = exp(-w*x); % Exponentiation of outer product.

### Compare fft and Discrete Transform Matrix Methods

n = 1024; X = eye(n); Xf = fft(X); % fft result f = 2*pi/n; w = (0:f:2*pi-f/2).' * 1i; x = 0:n-1; Xd = exp(-w*x); % matrix representation norm(Xf-Xd)

ans = 1.6769e-011

### Do You Have Good Links for Fourier Transform Teaching Material?

If you know of web sites with good material for teaching discrete Fourier transforms, would you please post them here? Thanks.

Get
the MATLAB code

Published with MATLAB® 7.7

## 4 CommentsOldest to Newest

Hey Loren,

I wrote a little bit about Fourier last year on my blog. Some people have found it useful, and hopefully your readers will too!

http://blinkdagger.com/fourier

Quan

Hi Loren,

In the recent years open courseware (OCW) has become very popular. Thanks to OCW anyone can freely access pedagogical materials in the form of video lectures from top universities presented by experienced and achieved researchers.

I can recommend the following very useful resources for learning about Fourier transforms (as well as many other topics):

The http://ocw.mit.edu/ and in particular linear algebra lectures by Prof. Gilbert Strang (see lecture 26 for discussion about complex matrices and the fast Fourier transform).

The OCW from Standord University and in particular: the Fourier transform and its applications lectures.

Another popular resource is located at videolectures.net.

Hope this is useful to others, happy learning :)

Kamil

Hello,

This question pertains to the sample code segment below which is provided in MATLAB help R2009a when searching ‘FFT’

The question pertains to line 12 below:

I don’t understand why the fft() function is divided by L and not (2*L).

As a sanity check I tried using this script for a simple DC signal with amplitude 2, Sample rate (Fs) = 102400 Hz,

t = 0:1/Fs:1

%%%%%%

Fs = 102400; t = 0:1/Fs:1; x = 2*ones(length(t),1);

%%%%%%

I expected to see an FFT plot with a peak magnitude of 2 at 0 Hz. Instead it shows a peak of 4. In order to obtain the corresponding time domain amplitude in the frequency domain, I simply modified line 12 to read:

This returns the correct amplitude.

Also out of curiosity, could someone provide some insight as to why this division by the record length was not incorporated into the fft function?

Scott-

As for the issue with the help example, I am not sure. What are you plotting, abs(fft) or fft^2? That could make the units on the plot look wrong as well. You should probably contact support (link on the right of the blog) and they may have an explanation.

To answer your second question, the normalization of the FFT is arbitrary and many books use different normalizations. It’s just important that the forward and inverse normalizations are paired correctly.

–Loren