ProakisSalehi_9.28MATLABSolution

ProakisSalehi_9.28MATLABSolution - - PART II, III OUTPUT...

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

View Full Document Right Arrow Icon
clear all; clc % *************** EXERCISE 9.28 - PART II,III *************** % Define Hamming code parameters n = 6; k = 3; m = n - k; % Create generator matrix, G P = [1 1 0; 1 0 1; 0 1 1]; G = [eye(k) P]; % The 2^k n-length codewords are defined by c=xG x = [0 0 0; 0 0 1; 0 1 0; 0 1 1; 1 0 0; 1 0 1; 1 1 0; 1 1 1]; c = mod(x*G,2); % Determine parity bit and append to each codeword parity_bit = mod(sum(c,2),2); c = [c parity_bit]; % The weight of each extended codeword is its distance from the 0 vector weight = sum(c,2); codeword_weight = [c weight]; dmin = min(weight(2:end)); % Calculate coding gain = dmin*(code rate) coding_gain = dmin*(k/(n+1)); % DISPLAY EXERCISE 9.28 - PART II, III OUTPUT disp(sprintf('***********************************************************')) disp(sprintf('********** EXERCISE 9.28
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: - PART II, III OUTPUT ***********')) 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+1)) disp(codeword_weight) disp(sprintf('dmin = %d', dmin)) disp(sprintf('CODING GAIN = dmin*(k/(n+1)) = %0.3f', coding_gain)) *********************************************************** ********** EXERCISE 9.28 - PART II, III OUTPUT *********** The matrix below displays the 8 7-bit codewords followed by the weight of each codeword in the last column. 0 0 0 0 0 0 0 0 0 1 0 1 1 1 4 0 1 0 1 0 1 1 4 0 1 1 1 1 0 0 4 1 0 0 1 1 0 1 4 1 0 1 1 0 1 0 4 1 1 0 0 1 1 0 4 1 1 1 0 0 0 1 4 dmin = 4 CODING GAIN = dmin*(k/(n+1)) = 1.714...
View Full Document

Ask a homework question - tutors are online