代做UESTC 4004 Digital Communications Lab 3: Channel Coding帮做R编程

Digital Communications

(UESTC 4004)

Lab 3: Channel Coding

The objective of this lab is to encode a message (e.g. first letter of your first name) with a given linear block code for forward error correction. The coded message is decoded using appropriate decoding scheme to recover the original message. The effectiveness of channel coding is to be demonstrated by recovering the original message accurately even in the presence of error producing noise.

Introduction

Linear code is an important type of block code used in error correction and detection schemes. Linear codes are applied in methods of transmitting symbols (e.g., bits) on communications channel so that, if errors occur in the communication, some errors can be detected by the recipient of the message block. A linear code of length n transmits blocks containing n bits or symbols. For example, the (7, 4) linear code is a binary linear code which represents 4 original message bits with 7 coded bits.

In linear block codes, the input is a k bit block (k message bits) and output is n bit block (n coded bits) with r=n-k check bits. With a k bit message block:

No of code words = 2k

Block length = n

Code rate = k/n

The check bits are determined by some predetermined rule.

U = m G

where:

U = code vector

m = message vector

G = Generator matrix which is defined as [ P | Ik ]; Ik is identity matrix of order k and P is the predefined encoding rule.

Matlab Syntax:

The encode function is used for encoding. The syntax is as follows.

code = encode(msg,n,k,'linear/fmt',genmat)

where, the codeword length is n and the message length is k.

msg represents data or message. It can be in decimal or binary format. The default value for this parameter is binary. We will use binary format in this lab session.

For example:

Format of msg can be a binary column vector as given below.

msg = [0 1 1 0 0 1 0 1 1 0 0 1]'. The ' symbol indicates matrix transpose.

Format of msg can also be binary matrix with k columns. In this case format of code will be binary matrix with n columns.

msg = [0 1 1 0; 0 1 0 1; 1 0 0 1]. Here k = 4.

For Linear Block codes, encode function encodes msg using genmat as the generator matrix.

genmat, a k-by-n matrix, is required as input.

Example:

The example below illustrates two different information formats (binary vector and binary matrix) for linear block code. The two messages have identical content in different formats. As a result, the two codes created by encode function have identical content in correspondingly different formats.

Here k = 11. And let r = 4 

r = 4; % r is the number of check bits.

k = 11;   % Message length

n = k + r % Codeword length = 15 using formula n-k=r

% Create 100 messages, k bits each.

msg1 = randi([0,1], 100*k,1); % As a column vector

msg2 = vec2mat(msg1,k);          % As a k-column matrix

% Create 100 codewords, n bits each.

P =[1

1

1

1;

0

1

1

1;

1

1

1

0;

1

1

0

1;

0

0

1

1;

0

1

0

1;

0

1

1

0;

1

0

0

1;

1

0

1

0;

1

0

1

1;

1

1

0

0]

genmat=[P eye(11)]; % concatenate P submatrix or predefined rule with Identity matrix.

code1 = encode(msg1,n,k,'linear/binary',genmat); code2 = encode(msg2,n,k,'linear/binary',genmat); if ( vec2mat(code1,n)==code2 )

disp('All two formats produced the same content.') end

Instead of randomly generating data words, you can create a data matrix of your own containing the data words that you want to encode.

Exercise 1 [6+6+2+2+2+2]: Given (6,3) linear block code generated by the predefined matrix P=[0 1 1; 1 0 1; 1 1 0].

a) Encode the messages [1 1 1] and [1 0 1] through MATLAB.

b) Encode all the possible messages in MATLAB and write the encoded words.

MESSAGE

CODE VECTOR

Weight

000

001

010

011

100

101

110

111

c) The minimum hamming distance = . (see lecture for reference)

d) The no. of errors this code can detect is (see lecture for reference)

e) The no. of errors this code can correct is (see lecture for reference)

f) The code rate = . (see lecture for reference)

Exercise 2 [30]: Given below is the MATLAB code to create 8x8 matrix representing letter ‘S’.

image = [ 1, 1, 1, 0, 0, 1, 1, 1;

               1, 1, 0, 1, 1, 0, 1, 1;

               1, 1, 0, 1, 1, 1, 1, 1;

               1, 1, 1, 0, 1, 1, 1, 1;

              1, 1, 1, 1, 0, 1, 1, 1;

               1, 1, 1, 1, 1, 0, 1, 1;

               1, 1, 0, 1, 1, 0, 1, 1;

               1, 1, 1, 0, 0, 1, 1, 1];

imshow(image);

Then using

P = [1 1 1 1;

0 1 1 1;

1 1 1 0;

1 1 0 1;

0 0 1 1;

0 1 0 1;

0 1 1 0;

1 0 0 1]

and encode function, encode your generated 8x8 matrix. You’ll have 8 coded words of 12 bits each. Remember the size of P is k x (n-k). This information will be helpful in calculating n and k.

3) Decoding linear block codes: Let Z stands for the received vector when a particular code vector U has been transmitted. Any transmission errors will result in Z ≠ U. The decoder detects or corrects errors in Z using stored information about the code.

A direct way of performing error detection would be to compare U with every vector in the code. This method requires storing all 2k code vectors at the receiver and performing up to 2k comparisons. But efficient codes generally have large values of k, which implies rather extensive and expensive decoding hardware.

More practical decoding methods for codes with large k involve parity check information derived from the code’s P submatrix. Associated with any systematic linear (n,k) block code is a(n-k)×n matrix called the parity check matrix H. This matrix is defined by

H = [Ir | P’]

Where Ir is the r × r identity matrix and n - k = r. The parity check matrix has a crucial property for error detection which is

ZHT = (0 0 0 0 …… 0)

provided that Z belongs to the set of code vectors. However, when Z is not a code vector, the product ZHT contains at least one nonzero element.

Therefore, given HT and a received vector Z, error detection can be based on

S = Z HT

an r-bit vector called the syndrome. If all elements of S equal zero, then either Z equals the transmitted vector U and there are no transmission errors, or Z equals some other code vector and the transmission errors are undetectable. Otherwise, errors are indicated by the presence of nonzero elements in S. Thus a decoder for error detection simply takes the form. of a syndrome calculator.

We develop the decoding method by introducing an n-bit error vector E whose non zero elements mark the positions of transmission errors in Z. For instance, if U = (1 0 1 1 0) and   Z = (1 0 0 1   1) then E = (0 0 1 0 1). In general,

Z = U Å E

And conversely,

U = Z Å E

Substituting Z = U + E into S = ZHT, we obtain

S = (U Å E)HT

S =UHT  Å EHT

S = EHT

which reveals that the syndrome depends entirely on the error pattern, not the specific transmitted vector.

Syndrome decoding example

An (8, 4) binary linear block code U is defined by systematic matrices:

0 1 1 1 | 1 0 0 0  1 0 0 0 | 0 1 1 1

G = 1 0 1 1 | 0 1 0 0  H = 0 1 0 0 | 1 0 1 1

1 1 0 1 | 0 0 1 0  0 0 1 0 | 1 1 0 1

1 1 1 0 | 0 0 0 1  0 0 0 1 | 1 1 1 0

Consider two possible messages:

m1 = [0 1 1 0] m2 = [1 0 1 1]

                          u1 = [0 1 1 0 0 1 1 0]                          u2 = [0 1 0 0 1 0 1 1]

Suppose error pattern e = [0 0 0 0 0 1 0 0] is added to both code words.

z1 = [0 1 1 0 0 0 1 0] z2 = [0 1 0 0 1 1 1 1]

Calculating the syndrome using S = ZHT. Here Z is the received erroneous code word. s1 = [1 0 1 1] s2 = [1 0 1 1]

The syndromes are the same and equal column 6 of H, so decoder corrects bit 6.

Exercise 3 [20+20+10]: Write MATLAB code to create a syndrome table that shows all the possible errors that the coder in above example could correct. You may seek help from the built-in MATLAB function(s). Once you know the error patterns, generate the syndrome vector corresponding to each error pattern.

If z = [ 0 1 1 1 0 1 1 0] is the received vector, what is the corresponding syndrome and at which position is the error, if any? Also, write the vector after correcting the error.

MATLAB Help:

1) DECODE:

Function: Block decoder

Syntax

msg = decode(code,n,k,'linear/fmt',genmat,trt) [msg,err] = decode(...)

[msg,err,ccode] = decode(...)

[msg,err,ccode,cerr] = decode(...)

Description: See MATLAB help

2) SYNDTABLE:

Function: Produces syndrome decoding table

Syntax:

t = syndtable(h)

Description: See MATLAB help

3) gen2par

Function: Convert between parity-check and generator matrices

Syntax

parmat = gen2par(genmat) genmat = gen2par(parmat)

Description: See MATLAB help


热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图