06.06.2022 Views

B. P. Lathi, Zhi Ding - Modern Digital and Analog Communication Systems-Oxford University Press (2009)

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

14. 13 MATLAB EXERCISES

14. 1 3 MATLAB Exercises 861

In this section, we provide MATLAB programs to illustrate simple examples of block encoders

and decoders. We focus on the simpler case of hard-decision decoding based on syndromes.

COMPUTER EXERCISE 14. 1

In the first experiment, we provide a program to decode the (6, 3) linear block code of Example 14.1.

% Matlab Program <Exl4 __ 1 .m>

% to illustrate encoding and decoding of (6,3) block code

% in ·Example 14 .1

%

G= [l 0 0 1 0 1 %Code Generator

0 1 0 0 1 1

0 0 1 1 1 0 ] ;

H= [l 0 1 %Parity Check Matrix

0 1 1

1 1 0

1 0 0

0 1 0

0 0 1] ';

E= [0 0 0 0 0 0 %List of correctable errors

1 0 0 0 0 0

0 1 0 0 0 0

0 0 1 0 0 0

0 0 0 1 0 0

0 0 0 0 1 0

0 0 0 0 0 1

1 0 0 0 1 0 ] ;

K=size (E,1);

Syndrome=mod (mtimes (E,H' ) ,2);

r= [l 1 1 0

display( ['Syndrome ' , 'Error

display (num2str ( [Syndrome

x=mod (r*H' ,2) ;

for kk=l :K,

if Syndrome (kk, :)==x,

idxe=kk ;

end

end

syndrome= Syndrome (idxe , :)

error=E ( idxe , : )

cword=xor (r,error)

1 1]

Pattern' ])

E] ))

%Find Syndrome List

%Received codeword

%Compute syndrome

%Find the syndrome index

%display the syndrome

%Error correction

The execution of this MATLAB program will generate the following results, which include the

erroneous codeword, the syndrome, the error pattern, and the corrected codeword.

Ex14 2

Syndrome Error Pattern

0 0 0 0 0 0 0 0 0

1 0 1 1 0 0 0 0 0

0 1 1 0 1 0 0 0 0

1 1 0 0 0 1 0 0 0

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!