BCH CODE - with codeword length

8 次查看(过去 30 天)
Waleed
Waleed 2013-12-7
hey guys, i really need help at the following BCH CODE
it did not work with me, im stuck now
here is the instruction:
Before encoding, you need to convert your data u into a Galois field array using the command gf(u,1).
ugf=gf(u,1);
Then encode ugf into a codeword v, using bchenc(); that's the BCH encoder function. You don't need to generate any polynomial.
Add binary noise z to v mod-2 (XOR) to get y. In order to add the noise mod-2, you'll have to convert your binary noise z to a Galois field array using gf(z,1) just as you did u.
The xor and mod operators won't work with v, since v is a Galois field array (necessary for bchenc() and bchdec()).
Decode y using the BCH decoder function bchdec().
The output of bchdec() will be uhat.
f you look at the example in doc bchdec(), be careful not to use the same noise or entire code, because the example is not doing what I'm doing.
here is what i did
clc
clear
n = 63;
k = 30;
u = randi ([0,1],k);
ugf=gf(u,1);
v = bchenc(ugf,n,k);
z = randi ([0,1],k);
zgf = gf(z,1);
for i = 1:1:k
for j = 1:1:k
if v==zgf
y(i,j)=0
else
y(i,j)=1
end
end
end
any help please?
  3 个评论
Waleed
Waleed 2013-12-7
well, i improved the code. however, the problem is when i want to add binary noise z to v mod-2 (XOR).
it won't give me the right answer it gives me this error Undefined function 'mod' for input arguments of type 'gf'.
Error in final_projecthoward1 (line 16) v=mod(v,2)
here is my code, clc clear n = 63; k = 30;
% u---> ugf---->v
u = randi ([0,1],n,k);
ugf=gf(u,1);
v = bchenc(ugf,n,k);
% z ---> zgf
z = randi ([0,1],k,n);
zgf = gf(z,1);
%the following loops to replace mod-2 for v
for i = 1:k;
for j = 1:n;
if v(i,j)==0;
y(i,j)=0;
else
y(i,j)=1;
end
end
end
%added V-mod2 to zgf
y=y+zgf
%here is U_hat
u_hat=bchdec(y,n,k);
Walter Roberson
Walter Roberson 2013-12-7
y(1:k, 1:n) = 1 - v(1:k, 1:n);
I do not see any "v = mod(v,2)" in your code.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Error Detection and Correction 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by