Generation of Hamming Codes problem

6 views (last 30 days)
Shabani  Nonda
Shabani Nonda on 22 Feb 2014
Commented: Shabani Nonda on 22 Feb 2014
Hi I am analyzing this code from my lab and it doesn't work because matlab can't find this bcd function. I tried typing help bcd and nothing appears. Can anyone tell me a solution how to make this code work? Thank you
p_err = 0.01; % bit error probability
n = 7; % codeword length
k = 4; % information word length
m = n-k; % number of parity bits
% generate matrix P (parity matrix)
P=[]; % initialize P
for iC=1:n
if (log2(iC)-floor(log2(iC)))>0 % check if position is not 1,2,4,8
P = [P bcd(iC,m)']; % form P
end
end
echo on
G = [eye(k),P'];
it gives this error: ??? Undefined function or method 'bcd' for input arguments of type 'double'.
Error in ==> test1 at 10 P = [P bcd(iC,m)']; % form P

Answers (1)

Walter Roberson
Walter Roberson on 22 Feb 2014
bcd is not a routine supplied by Mathworks in any of their toolboxes. You will need to look again at the location you found that code. For example it might happen to say
The formation of the generator matrix is simply a matter of arranging binary coded decimal
(BCD) vectors of m bits in numerical order, where m=n-k is the number of parity bits.
Hint: binary coded decimal is the same as binary when the values involved are less than 10.

Categories

Find more on Just for fun in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!