Introduction
This lab is a revision of the Discrete Fourier Transform (DFT), and the
Fast Fourier Transform (FFT), and an introduction to the Short-Time Fourier Transform (STFT) and the
spectrogram.
The outcomes from the lab are to be handed in as a “folder” of results, showing that
you have completed the steps of the lab successfully. A box in the right-hand
margin indicates where an outcome is expected – like this:
The Matlab programs you write will be short: you can print them out if you wish, but
hand-written listings are OK too. Sketch graphs are also OK.
1. Getting Started
In your home directory, create the subdirectories “EBU6018” and “EBU6018/lab1”.
Start Matlab. Use “cd ” to get into the directory “lab1” you have just
created.
2. Discrete Fourier Transform
In Matlab, type “edit” to start the Matlab editor.
Create a Matlab function in the file “dft.m” to calculate the Discrete Fourier
Transform of a signal. Recall that the DFT is given by [Qian, eqn (2.34)]
[NB: The “j” is missing in Qian’s definition of WN on p33.]
Hints:
• Start your function with
function sw = dft(st)
so “st” is the time waveform vector, and “sw” is the frequency waveform vector
• Matlab vectors (e.g. st and sw) start from 1, not zero, so use “n-1” and “m-1” to
refer to the appropriate element
• Assume that N=M, and use the “length(st)” to find the value to use for these.
An example outline for your Matlab function is provided below.
EBU6018 Advanced Transform Methods
Lab 1: DFT, FFT and STFT
Department of Electronic Engineering and Computer Science
Example DFT function outline in Matlab
Generate some waveforms to test your function. Test your dft on at least the
following signals:
• Uniform function: “s=ones(1,64);”
• Delta function: “s = ((1:64)= =1);”
[NB: “1:64” generates the vector (1 2 … 64) ].
• Sine wave: “s = sin(((1:64)-1)*2*pi*w/100)” for various values of w.
Why do we need to use “(1:64)-1”?
What values of w give the cleanest dft?
What happens if we use “cos”?
• Symmetrical rectangular pulse: “s = [0:31 32:-1:1]