ProakisSalehi_9.24MATLABSolution

ProakisSalehi_9.24MATLABSolution - disp(sprintf('The matrix...

This preview shows page 1. Sign up to view the full content.

clear all; clc % *************** EXERCISE 9.24 *************** % Define Hamming code parameters n = 7; k = 4; m = n - k; % Create generator, (G) and parity-check, (H) matrices P = [0 1 1; 1 1 0; 1 1 1; 1 0 1]; G = [eye(k) P]; H = [P' eye(m)]; mod(G*H', 2); % The 2^k n-length codewords are defined by c=xG x = [0 0 0 0; 0 0 0 1; 0 0 1 0; 0 0 1 1; 0 1 0 0; 0 1 0 1; 0 1 1 0; 0 1 1 1; 1 0 0 0; 1 0 0 1; 1 0 1 0; 1 0 1 1; 1 1 0 0; 1 1 0 1; 1 1 1 0; 1 1 1 1]; c = mod(x*G,2); % The weight of each codeword is its distance from the 0 vector weight = sum(c,2); codeword_weight = [c weight]; % DISPLAY EXERCISE 9.24 OUTPUT disp(sprintf('*****************************************************')) disp(sprintf('*************** EXERCISE 9.24 OUTPUT ****************'))
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: disp(sprintf('The matrix below displays the %d %d-bit codewords followed by the weight of each codeword in the last column.\n', 2^k, n)) disp(codeword_weight) ***************************************************** *************** EXERCISE 9.24 OUTPUT **************** The matrix below displays the 16 7-bit codewords followed by the weight of each codeword in the last column. 0 0 0 0 0 0 0 0 0 0 1 1 0 1 3 0 0 1 0 1 1 1 4 0 0 1 1 0 1 0 3 0 1 0 0 1 1 0 3 0 1 0 1 0 1 1 4 0 1 1 0 0 0 1 3 0 1 1 1 1 0 0 4 1 0 0 0 0 1 1 3 1 0 0 1 1 1 0 4 1 0 1 0 1 0 0 3 1 0 1 1 0 0 1 4 1 1 0 0 1 0 1 4 1 1 0 1 0 0 0 3 1 1 1 0 0 1 0 4 1 1 1 1 1 1 1 7...
View Full Document

This note was uploaded on 08/05/2008 for the course ELEN E4702 taught by Professor Lazano during the Summer '08 term at Columbia.

Ask a homework question - tutors are online