matlab bchenc,BCH encoder

Set the BCH parameters for a Galois array of GF(2).

M = 4;

n = 2^M-1; % Codeword length

k = 5; % Message length

nwords = 10; % Number of words to encode

Create a message.

msgTx = gf(randi([0 1],nwords,k));

Find the error-correction capability.

t = bchnumerr(n,k)

t = 3

Encode the message.

enc = bchenc(msgTx,n,k);

Corrupt up to t bits in each codeword.

noisycode = enc + randerr(nwords,n,1:t);

Decode the noisy code.

msgRx = bchdec(noisycode,n,k);

Validate that the message was properly decoded.

isequal(msgTx,msgRx)

ans = logical

1

Increase the number of possible errors, and generate another noisy codeword.

t2 = t + 1;

noisycode2 = enc + randerr(nwords,n,1:t2);

Decode the new received codeword.

[msgRx2,numerr] = bchdec(noisycode2,n,k);

Determine if the message was properly decoded by examining the number of corrected errors, numerr. Entries of -1 correspond to decoding failures, which occur when the codeword has more errors than can be corrected for the specified [n,k] pair.

numerr

numerr = 10×1

1

2

-1

2

3

1

-1

4

2

3

Two of the ten transmitted codewords were not correctly received.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值