- As much as possible, the TAs, grader and I would like to give you
feedback on your critical thinking processes on all assignments in
the class.
To this end, the grader has given the following feedback on
homework assignments:
- Please keep all parts of a question together. Avoid separating the code/plots from the rest of the question. Remember that both code and plots need to be included and legible in order to get full credit.
- Label graph axes, including units. Missing or incorrect units may result in point deduction.
- When doing calculations, keep them in order with your final solution at the end (or the bottom). Simplify as much as possible, including convolutions.
- Show all of your work. Do not just give a final answer.

- For the names of Matlab functions for common signals,
please see
Common Signals in Matlab.
You can receive help on a particular Matlab command by typing
`help exp`

and use the`lookfor`

command to find a Matlab command for a given task. - Problem 1.1.
This problem concerns four commonly used building blocks in systems.
(a) The problem concerns a five-tap (or five-coefficient) discrete-time averaging filter.

The five-tap discrete-time averaging filter, with input x[n] and output y[n], is described by

y[n] = 1/5 x[n] + 1/5 x[n-1] + 1/5 x[n-2] + 1/5 x[n-3] + 1/5 x[n-4]

Five taps means five terms. To compute the current output y[n], we average the current input value x[n] and the previous four input values.(c) The discrete-time analogy to integration is summation. For the discrete-time integrator, the relationship between the input x[n] and output y[n] for n ≥ 0 becomes

n ---| \ y[n] = | x[m] / ---| m = 0

The above equation is not terribly efficient as the amount of memory to store previous input values grows without bound as n increases. A computationally efficient version of the equation is given below:*y*[*n*] =*y*[*n*-1] +*x*[*n*]

with initial condition*y*[-1] = 0 - Problem 1.2:
For cos( angle(t) ), the instantaneous frequency in rad/s is d/dt angle(t).
- Consider the familiar case of angle(t) = 2 pi f0 t. Instantaneous frequency is 2 pi f0.
- For the chirp signal, angle(t) = 2 pi (f0 + 1/2 fstep t) t. Instantaneous frequency is 2 pi (f0 + fstep t).

(b) The Matlab command

`plotspec`

is defined by the Matlab file plotspec.m that comes with the JSK book. The`plotspec`

function takes the time-domain signal and the sampling time as arguments, and plots the time-domain waveform and the magnitude of its Fourier transform. The Fourier transform give the average frequency content in the time-domain signal, and does not indicate at what times the frequencies occur.The

`plotspec`

command will accept the vector of amplitude values in the time domain and a sampling period T_{s}. It will plot the signal in the continuous-time domain (top plot) and in the frequency domain (bottom plot). The time-domain plot assumes that the time-domain signal starts at t = 0. The magnitude response will be plotted over the frequencies -1/2 f_{s}to 1/2 f_{s}, where f_{s}is the sampling rate.*Matlab has its own*`plotspec`

function that takes three arguments and plots a time-frequency signal representation called a spectrogram. This is a very different function from the`plotspec`

function in the JSK textbook.To access the functions provided by the Matlab files that accompany

*Software Receiver Design*textbook, the directory containing the Matlab files would need to placed first on the Matlab search path. Please see the Matlab hints for more information.(c) Matlab code to play it over speakers / headphones:

%%% Generate chirp signal with frequency %%% increasing from f0 to (f0 + fstep time) over time seconds time = 10; f0 = 20; fstep = 420; fs = 44100; Ts = 1 / fs; %%% Add code here to define chirp signal y = cos( angle(t) ) sound(y, fs)

(d) Please create a new plot window to plot the spectrogram by using the Matlab command

figure;

The spectrogram will be hard to follow if it appears in the plot window used by the JSK plotspec command. Here is an example use of the spectrogram function:spectrogram(y, hamming(256), 128, 256, fs, 'yaxis');

The fourth argument indicates the number of points in the fast Fourier transform, and this can be any positive integer. It does not have to be a power of two. The third argument is how much shift is applied to the the previous block of samples to find the current block. The second argument indicates any weighting of the data in block of samples before the fast Fourier transform is applied.A Hamming window has finite duration, and is even symmetric about the midpoint with endpoints having value 0.08. The amplitude values of the causal Hamming window of length

*N*samples is defined asw[n] = 0.54 - 0.46 cos(2 pi n / (N - 1))

for*n*= 0, 1, ...,*N*-1. One can plot a 256-point Hamming window in Matlab by evaluating the commandstem(hamming(256));

- Problem 1.3:
Please read the comments in the upconvertGong.m file.
(a) Mean squared error (MSE) is a measure of signal quality between signals x[n] and y[n]:

M-1 2 MSE = Sum (x[n] - y[n]) n=0

where M is the number of samples to be compared.In computing the mean squared error between the message signal at the transmitter (

`basebandInput`

) and the message signal decoded at the receiver (`basebandOutput`

), one also has to take into account the delay in the transmitter and receiver. The only delay is in the lowpass filter used in the receiver.The group delay through a finite impulse response filter whose N coefficients are even symmetric about the midpoint of the filter's impulse response is (N-1)/2. We'll derive this formula in lecture 5 slides. In order for the group delay to be an integer, N must be odd.

We can force the filter length to be odd by replacing

FIRlength = floor(fs/f1);

with%%% Use an odd-length FIR filter FIRlength = floor(fs/f1); if 2*floor(FIRlength/2) == FIRlength FIRlength = FIRlength - 1; end

To implement the group delay GD, we'll need to remove the first GD samples from`basebandOutput`

and the last GD samples from`basebandInput`

.(b) You're asked to use a squaring block followed by a lowpass filter to realize downconversion. An advantage of using the squaring block is that the receiver would not need to know the carrier frequency to perform downconversion. The baseband bandwidth in the receiver will be larger than that of downconversion by sinusoidal amplitude demodulation. You'll need to modify the following Matlab code accordingly:

FIRlength = floor(fs/f1);

You will also need to adjust the gain in the receiver.Please read the comments in upconvertGong.m.

More information about using a squaring block in downconversion is available on slides 5-8 and 5-9 by Prof. Stephen Tretter.

Last updated 09/14/18. Send comments to bevans@ece.utexas.edu