Computer Homework 1

Tuesday, 10 February 1998

I received the following question today about the homework. Since it made me realise that I'd made a mistake in the wording, please read carefully.

> On part 2 of the computer homework, you have us plotting a sine wave with
> f=800 Hz against a time(sampling) vector with sampling frequency fs=8000
> Hz. Using the basic "plot" command, matlab linearly interpolates among
> the samples. The result is not a smooth sine wave (only 10 samples per
> period).

Well, I warned y'all that I make mistakes, and here is the first! What I wanted was actually 200 Hz. Four cycles of that lasts 20ms, and contains 160 samples. Sorry about that!

> I know a perfect representation of the 800 Hz wave is possible with
> sampling as low as 1600+ Hz if I use sinc interpolation.

Correct. However, usually we won't be worrying about the interpolation method used - we will stay in the discrete time domain. We assume that, ultimately, the discrete time signal will be converted to continuous time by passing it through a perfect brickwall filter with a cutoff frequency equal to fs/2.

Incidentally, I don't usually think about 'sinc interpolation'. I find the frequency domain representation (i.e., removing images centered at 2pi, 4pi etc by lowpass filtering) more intuitive. For one thing, the reconstruction is invariably done by an analog filter, which in no way performs sinc interpolation!

Tom


Sunday, March 1 1998

In general:

The computer homework was well done. There were quite a few for loops and if statements; where possible, I indicated alternative vectorized code. Please look at the posted solution outside Dr. Bovik's door, and at the code on the ftp site. To access this code, ftp to pepperoni.ece.utexas.edu, log on as 'anonymous' and type your name at the password prompt. Then type cd pub/Assignments and download the files you want.

Part 1:

There are easy and hard ways to construct the triangle and pulse waves. I considered the triangle wave to be a sine wave, modified by a static distortion of the form y = asin(x), properly scaled. This allows a triangle to be created even if the input time vector is very short. The pulse wave can be generated by finite differencing the triangle wave twice, or by finding peaks in the triangle wave (which is what I did). Some placed pulses where the triangle vector was maximum (and minimum), but this will not work for aperiodic inputs, since in that case it is possible that only one element in the entire triangle vector will be equal to the maximum value. We want local maxima here, not global maxima.

Part 3:

My comments are in the posted solution. Note that the fact that the triangle wave has only odd harmonics has NOTHING AT ALL to do with the fact that it is (according to some) an odd function. The triangle wave is not an odd function by definition; in fact, it can be odd, even, or neither, depending on its phase at t=0. In all cases, it contains only odd harmonics.

The reason the triangle has odd harmonics only is that the positive-going half of the wave is the exact negative of the negative-going half. This implies that the polynomial expansion of the triangle wave is of the form ax + bx^3 + cx^5 +..., since any even powers of x cause asymmetry in the two halves. Odd powers of x mean odd harmonics only. The same is true of the pulse wave used here.

Parts 4, 5, 6:

My comments are in the posted solution. Please read them if you are in one of the following categories:

(1) Your freq. response of the sine wave was not a single peak;
(2) You stated that the triangle wave was smaller because 'energy had been filtered out';
(3) You failed to speculate on the results of repeated applications of the filter to the pulse wave; or
(4) You do not fit in categories (1), (2) or (3).

Tom