Generation of Hamming Codes problem

조회 수: 6 (최근 30일)
Shabani  Nonda
Shabani Nonda 2014년 2월 22일
댓글: Shabani Nonda 2014년 2월 22일
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

답변 (1개)

Walter Roberson
Walter Roberson 2014년 2월 22일
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.
  댓글 수: 1
Shabani  Nonda
Shabani Nonda 2014년 2월 22일
Thanks for your reply Walter!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by