Note: For our simulations we use Matlab. Matlab only works with discrete signals, not continuous signals, so the simulation is not exact. Some of the things we must do in the simulation are because we are using discrete signals, or samples of continuous signals, and why they are done will not be obvious until you take a class in digital signal processing.

Please follow all the guidelines for computer homework. Homework that does not follow the guidelines will be returned without being graded.

Computer Homework 1

In this homework you will simulate signals passing through band limited channels. In part 1 you will simulate several pulse signals and see the effect of the channel on each.

In part 2 you will send a rectangular pulse through the channel while varying the bandwidth of the channel.

For this homework, let us use similar numbers as in the example in class. The frequency bandwidth of the channel is from 30 to 3300 Hz. To simplify our problem, let us assume the bandwidth will be from 0 to 3300 Hz. The bandlimited channel will be simulated as a lowpass filter with a cutoff of 3300 Hz. We will leave noise for a later homework.

Part 1

First make the channel, or LPF, and plot the magnitude bode plot. After this, make three signals, a sine pulse, a rectangular pulse, and a triangular pulse. Pass the signals through the channel and plot the input and the output. Note the differences between the input and the output.

A. Making the lowpass filter:

1. Define a sampling frequency (digital signals):

>>fs=1/0.00001;

2. Define the cutoff frequency of the filter: (in this case 3300 Hz.)

>>fp=3300/(fs/2);

3. Calculate the filter coefficients: (5 is the filter order, this can be changed if you like.)

>>[b,a]=butter(5,fp);

4. Look at the filter in the frequency domain: (a magnitude Bode plot)

>>[H,f]=freqz(b,a,1000,fs);

>>plot(f,20*log10(abs(H)))

>>axis([0 4000 -20 10])

To write labels for the figure and the x and y axes, look at the sample matlab programs.

B. Making the signals:

1. A sine pulse:

>>fc=1070;

>>T=1/300;

>>t=-T/2:1/fs:T/2;

>>g=[zeros(1,1000),cos(2*pi*fc*t),zeros(1,1000)];

To look at the sine pulse:

>>plot(g)

To look at part of the sine pulse:

>>plot(g(900:1500))

2. A rectangular pulse

>>g=[zeros(1,1000) ones(1,300) zeros(1,1000)];

You can look at this pulse the same way as the sine pulse.

C. Passing the signals through the channel. (Filtering the signal)

>>y=filter(b,a,g);

here, g is the input signal, y is the output signal, and b and a are the filter coefficients.

Part 2

Here you will use a rectangular pulse, and pass it through three channels. The bandwidth of the channel is up to you. Make shure you choose channels that make the output signal look diferent. The design of the filter and signal is described in part 1.