ECD312:Digital Communication and Systems Assignment: 1 (20 Points)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

ECD312:Digital Communication and Systems

Assignment: 1 (20 Points)


1. Waveform Coding of an Analog Source

Consider waveform coding of a speech signal given as

x(t) = A1 cos(2πf1 t) + A2 cos(2πf2 t)


√ √
where A1 = 6 2, A2 = 8 2, f1 = 1 Hz and f2 = 2 Hz.
a) We wish to sample the signal x(t) using a sampling rate fs = 20Hz. Generate and
plot the sampled sequence x[n] for a time interval of 50 seconds.
b) Write a function [xq , D] = my uquant(x, M ) which performs uniform scalar quan-
tization on the input analog sequence. The function takes as inputs the input sequence
x[n] and the number of quantization regions M and it outputs the quantized sequence
xq [n] and the total mean squared distortion D.
c) Apply the quantizer developed in (b) on the signal generated in (a) with M = 2t
and plot the quantized signal for t=8. Compute and plot the SQNR for t=2,4,8 and 16.
d) Write a function for µ-law compander [xhat ] = my mucompand(x, µ, compress/expand)
which performs µ-law compression and µ-law expansion respectively on the input sequence
x[n] depending on the specified operation.
e) If the samples x[n] are first applied to a µ-law compressor with µ = 200 and then
to a uniform quantizer with M = 28 levels and then to a µ-law expander, find the SQNR
obtained with this non-uniform quantization. Use the functions developed in (d) and (b).

2. Design of an optimal Nonuniform Quantizer

We wish to design a nonuniform quantizer such that it minimizes the total mean squared
−1
error distortion. We need to find the boundary points {ai }M i=1 and quantization levels
M
{x̂i }i=1 such that it minimizes the mean-squared error distortion D. This quantizer is also
known as a Lloyd-Max quantizer.
−1
a) Write a function [D, {ai }M M
i=1 , {x̂i }i=1 ] = my lloydmax(M ) which computes the
resulting mean-squared distortion, boundary regions and quantization levels for given M.
Assume that the input is Gaussian distributed with zero mean and unit variance.
b) Generate a sequence of independent and identically distributed Gaussian random
variables of length 1000 with mean 0 and variance 1. Apply the non-uniform quantizer
developed in (a) on this data sequence with M = 10 and find the mean-squared distortion.
Compare the results in two parts.

2. Coding of a Discrete Source

Given a K-ary Discrete memoryless source U , with K input symbols u1 , u2 , · · · , uK and


corresponding probabilities P r(U = ui ) = pi for i = 1 · · · K.
a) Write a function H = my entropy(p, D) which computes the entropy HD (U ) of the
source U . The function takes the given probability mass function p = [p1 , p2 , · · · , pK ] as
input.
b) Write a function [L, C] = my huffman(p) which computes a binary Huffman code
for the source. The function takes given probability mass function as input and outputs
the average length L of the code and a cell-array C of length K containing variable length
codes for each source symbol.
c) Consider a discrete memoryless source with input symbols and corresponding prob-
abilities as given in figure below. Determine the entropy of this source using the function
developed in (a) and design an optimal variable length code for this source using the
function developed in (b). What is the efficiency of the code?

Figure 1: Figure for Problem 1

d) Suppose, now we wish to encode two source symbols jointly at a time for the given
source in (c). Construct a binary Huffman code for a second order extension of this source
and find the efficiency of the code (use the function developed in (b)).

2. Linear Block Codes

We wish to encode an input bit sequence using a (7,4) Hamming code and transmit
the encoded bit sequence over a binary symmetric channel with cross-over probability
p = 0.1. The received sequence is decoded using syndrome decoding and compared with
input bit sequence to find the bit error rate.
a) Write a function [G, H] = my hamming(n, k) where n=7 and k=4, which lists all
possible codewords of a (7,4) Hamming code and outputs the generator matrix G and
parity check matrix H in systematic forms.
b) Generate a random information sequence of 1000 bits of 0s and 1s and encode this
using the code generated in (a).
c) Write a function to implement a binary symmetric channel with cross-over proba-
bility p i.e. [r] = my bsc(v, p) where v is the input binary sequence to the channel and r
is the output binary sequence from the channel.
d) Transmit the encoded sequence generated in (b) through the channel in (c) and
perform syndrome decoding over the received data. Compute the bit error rate. Compare
this with the bit error rate when no error correcting code is used.

2. Convolutional Codes

We wish to encode an input bit sequence using a (n,1,m) convolutional code and transmit
the encoded bit sequence over a binary symmetric channel with cross-over probability
p = 0.1. The received sequence is decoded using Viterbi decoding and compared with
input bit sequence to find the bit error rate.
a) Write a function [v] = my convcoder(u, g) which encodes a given sequence u using
(n,1,m) convolutional code with given generator sequences g = [g 1 , g 2 , · · · , g n ] where each
g i is a binary vector of length (m+1).
b) Write a function [uhat ] = my viterbidec(r, g) which decodes a given sequence r
using (n,1,m) convolutional code with given generator sequences g = [g 1 , g 2 , · · · , g n ] where
each g i is a binary vector of length (m+1).
c) Generate a random information sequence of 1000 bits of 0s and 1s and encode
this using the encoder implemented in (a) with g =[1 1 1, 1 0 1, 1 1 0]. Transmit the
encoded sequence through the channel implemented in 4(c) and perform Viterbi decoding
implemented in (b) over the received data. Compute the bit error rate. Compare this
with the bit error rate when no error correcting code is used.

Submission Guidelines
• Submit a soft copy of your well documented MATLAB/C/C++ programs. Include a
README file that will have description of all the programs that are included in your zip
file.

• Also include a copy of your programs and obtained results in PDF format.

• Email id for submitting the assignment will be communicated later.

• Last day for submission of this assignment is Nov 5th, 2018.

References
• ’Modern Digital and Analog Communication Systems’, by B. P. Lathi and Zhi Ding.

• ’Fundamentals of Communication Systems’, by Proakis and Salehi.

• ’Contemporary Communication Systems using MATLAB’, by Proakis and Salehi.

• ’Elements of Information Theory’, by Thomas Cover and Joy thomas.

• https://in.mathworks.com/matlabcentral/fileexchange

• https://in.mathworks.com/help/comm/

You might also like