MMA410 - Fourier and Wavelet Analysis
About Assignement 1

A first exercise

If you wish to do something more fun than just plotting sinfunctions and their spectra (i.e. the Fourier transform), you could do something like this.

  • Take a sound recording in a suitable format, and use matlab to sample it. I have here the beginning of one of my daughter's disks, croc1.wav , which you also could download.
  • With matlab, use the command [crs,Fs,bits] = wavread('filename')
    Then the varable crs will contain the sampled values, Fs will contain the sample rate, and bits will contain the number of bits stored in each sample. In my case the sample rate is about 11000, and the number of bits is 8. Its a mono-signal, and so crs happens to be a 46456x1 vector (the wave-file corresponds to about 4 seconds of music)
  • Now you can plot the signal, most easily just do plot(crs)
  • Next try to find the spectrum of this signal:
    crocspec = fft(crs);
  • We now do a most trival kind of filtering (but think of why I did it this way, and how it should really be done!)
    crocspec2 = crocspec;
    crocspec2(5000:46456-5000) = 0;   (what does this imply?)
    crs_filtered = ifft(crocspec2);
  • If you happen to do this on a pc, you chould be able to listen to the two .wav-files and hear the difference.
  • It should also be possible to listen to the filtered signal directly by using the command
    sound(crs_filtered,Fs,bits); this might work directly on the unix-computers.

To create and use filters

Note that this is not a course in the theory of filters ....

  • The matlab function filter can be used to pass a digital signal, such as the crocsample that was created above. The usage is
    crs_filter1 = filter(num,1,crs);
    and then you can look at this file, directly, or at the spectrum after passing the signal through fft as above.
  • The first to arguments to filter are the parameters that define the filter. The filter is defined by a rational function, i.e. the quotient of two polynomials. If the denominator is identically 1 as in the example, the filter is of type "FIR". The vector num determines if it is a high pass or low pass or other kind of filter.
  • The vector num can be created in the following way.
    1. Open the Digital Filter Design & Analysis Tool by typing fdatool in matlab.
    2. You will then find a graphical user interface, where you can experiment with different parameters, and create different types of design. Note that for the example above, it is useful to set Fs = 11025.
    3. When you are happy with the paramaters, click Design filter
    4. .... and then export the result using the File-menu: Export. Use Export to workspace.
    5. Some examples are available in the file filtercoefficienter.mat that you can put in your matlab-directory. After typing load filtercoefficienter you should have two variables Num1 and Num2 that you can use with the filter command. One of them is a high pass filter, and the other is a low pass filter of high orders.

Bernt Wennberg <>