The specified codeword length and message length are not valid with using encode hamming

8 views (last 30 days)
Hello,
i have this code to encode a 7 bit sequence to a 11 bit hamming code.
n = 11;
k = 7;
data = randi([0 1],k,1);
encData = encode(data,n,k,'hamming/binary');
but i get this error:
The specified codeword length and message length are not valid.
How can i solve this problem?

Answers (1)

Walter Roberson
Walter Roberson on 10 Jun 2017
The formula works out such that you can only encode messages of length k if k = 2^n - n - 1 for some integer n. For example, messages of length 4 11 26 57 120 247 502 1013 2036 4083 ...

Community Treasure Hunt

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

Start Hunting!