ECD312:Digital Communication and Systems Assignment: 1 (20 Points)
ECD312:Digital Communication and Systems Assignment: 1 (20 Points)
ECD312:Digital Communication and Systems Assignment: 1 (20 Points)
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.
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)).
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.
References
• ’Modern Digital and Analog Communication Systems’, by B. P. Lathi and Zhi Ding.
• https://in.mathworks.com/matlabcentral/fileexchange
• https://in.mathworks.com/help/comm/