You will use Matlab to run experiments and for solving some of the homework
problems.
Getting started
It is not difficult to learn how to use Matlab, do
invest some time at the beginning of the class to familiarize yourself.
First of all, make sure that you have a computer account from which you
can run Matlab. An excellent way to start is to ask a friend to
show you some code they wrote and to explain to you what it does. Another
place where you may start is Kermit Simon's Matlab Primer of which
you may download either a PS
or a PDF
version. You will find online
versions as well.
1st week assignment
Familiarize yourself with the Matlab functions fft, conv and conv2,
plot, sound. Try and understand how the output of fft is organized
(run the command `help fft' to find out).
Try the following (this may not work on a Linux box):
> load chirp
> sound(y,Fs)
Now calculate the power spectrum of the signal y and plot it.
Plot the signal as well and look at it. Is it a lowpass signal or a bandpass
signal?
Computing Fourier transforms in Matlab (Jan 13 2001)
-
The command fft will compute a
discrete Fourier transform in Matlab. The coefficients are stored in the
output vector in a funny order that is explained in the Matlab on-line
help. Type help fft to find out
more. Matlab provides you with the command fftshift
to reorder the coefficients into a more familiar format. Two more commands,
ifft
and ifftshift are needed
to compute the inverse Fourier transform.
-
Sometimes the inverse Fourier transform will deliver to you a complex signal
even when you thought that the signal should be real. This is due to rounding
errors in the code. To verify this check the magnitude of the coefficients
in the imaginary part. If your code is correct then the coefficients will
be small (same order of magnitude as eps
- type help eps to find out more).
-
Execute the code in fft_demo.m
and understand the details of this example.
-
Some normalization constants in the Ft may be different from the definition
you find in the textbook. You may use either definition but remember to
be consistent.
Matlab code for diffusions
demo shown in class on Wed March 7