Generation of Hamming Codes problem

7 vues (au cours des 30 derniers jours)
Shabani  Nonda
Shabani Nonda le 22 Fév 2014
Commenté : Shabani Nonda le 22 Fév 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

Réponses (1)

Walter Roberson
Walter Roberson le 22 Fév 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.
  1 commentaire
Shabani  Nonda
Shabani Nonda le 22 Fév 2014
Thanks for your reply Walter!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Just for fun dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by