Мне очень срочно нужна помощь в понимании этой программы. Я не понимаю как работают и зачем вообще есть некоторые куски кода, которые приведены после кода программы.
h = comm.BCHEncoder('CodewordLength', 31, 'MessageLength', 21); %object zanimaushisa kodirovaniem
msg = [1 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 1 0 1 0 0]; %б®®ЎйҐЁҐ ў Ї®«Ґ ѓ «г /Message in Galois array
obj = comm.BCHEncoder('CodewordLength', 31, 'MessageLength', 21);
c1 = step(obj, msg(1,:)'); %zakodirovannoe soobshenie
cbch = [c1].';
coded = cbch;
% parametri
m=5;
n=2^m-1; %dlina soobshenia
t=2;
k=2^m-1-m*t;
%Є®бв вл, ЁбЇ®«м§гҐ¬лҐ ў «Ј®аЁв¬Ґ/the constants used in the algorithm
alpha = gf(2, m);
zero = gf(0, m);
one = gf(1, m);
%since all zero is always a codeword, only have to specify the
%error/vruchnuu zabili oshibki
coded(1) = 0;
coded(2) = 1;
code=gf(coded, 1); %massiv polei galua
codev = code.x; %dlya drugih vichislenii perevodim v massiv|ot massiva polei galua k obichnoi matrice
reccode=gf(codev, m);
%ᮧ¤ Ґ¬, «мд ¬ ббЁўcreating alpha array
%note that syndrome should be in the order [s3, s2, s1, s0] v obratnom poradke
alpha_tb=gf(zeros(1, 2*t), m);
for i=1:2*t,
alpha_tb(i)=alpha^(2*t-i+1);
end;
%ЈҐҐаЁа㥬 ᨤ஬/syndrome generation
syndrome=gf(zeros(1, 2*t), m)
for i=1:n,
syndrome=syndrome.*alpha_tb+reccode(i);
end;
%imba
lambda = gf([1, zeros(1, t)], m);
lambda0= lambda;
b=gf([0, 1, zeros(1, t)], m);
b2 = gf([0, 0, 1, zeros(1, t)], m);
k=0;
gamma = one;
delta = zero;
syndrome_array = gf(zeros(1, t+1), m);
for r=1:t,
r1 = 2*t-2*r+2;
r2 = min(r1+t, 2*t);
num = r2-r1+1;
syndrome_array(1: num) = syndrome(r1:r2);
delta = syndrome_array*lambda';
lambda0 = lambda;
lambda = gamma*lambda-delta*b2(2:t+2);
if((delta~= zero) && (k>=0))
b2(3)=zero;
b2(4:3+t) = lambda0(1:t);
gamma = delta;
k = -k;
else
b2(3:3+t) = b2(1:t+1);
gamma = gamma;
k=k+2;
end
end;
%massiv v obratnom poradke, tak kak alfa massiv mi zapisivali v obratnom
inverse_tb = gf(zeros(1, t+1), m);
for i=1:t+1,
inverse_tb(i) = alpha^(-i+1);
end;
%Ї®ЁбЄ —ЁҐ /chien's search
lambda_v = zero;
accu_tb=gf(ones(1, t+1), m);
for i=1:n,
lambda_v=lambda*accu_tb';
accu_tb = accu_tb.*inverse_tb;
if(lambda_v==zero)
error(1,n-i+1)=1;
else
error(1,n-i+1)=0;
end
end
found = find(error(1,:)~=0)
disp(coded);
sz = size(found); %proidemsa po found
length = sz(2);
for i=1:length,
if(coded(i)==0)
coded(i) = 1;
else
coded(i) = 0;
end
end
disp(coded);
hh = comm.BCHDecoder('CodewordLength', 31, 'MessageLength', 21); %decodiruem ispravlennoe
obj = comm.BCHDecoder('CodewordLength', 31, 'MessageLength', 21);
d1 = step(obj, coded(1,:)'); %informazia dljya vosstanovlenia dobavlaetsa
dbch = [d1].';
disp(dbch);
1)
code=gf(coded, 1); %massiv polei galua
codev = code.x; %dlya drugih vichislenii perevodim v massiv|ot massiva polei galua k obichnoi matrice
reccode=gf(codev, m);
2)
%ᮧ¤ Ґ¬, «мд ¬ ббЁўcreating alpha array
%note that syndrome should be in the order [s3, s2, s1, s0] v obratnom poradke
alpha_tb=gf(zeros(1, 2*t), m);
for i=1:2*t,
alpha_tb(i)=alpha^(2*t-i+1);
end;
3)
%ЈҐҐаЁа㥬 ᨤ஬/syndrome generation
syndrome=gf(zeros(1, 2*t), m)
for i=1:n,
syndrome=syndrome.*alpha_tb+reccode(i);
end;
4)
%imba
lambda = gf([1, zeros(1, t)], m);
lambda0= lambda;
b=gf([0, 1, zeros(1, t)], m);
b2 = gf([0, 0, 1, zeros(1, t)], m);
k=0;
gamma = one;
delta = zero;
syndrome_array = gf(zeros(1, t+1), m);
for r=1:t,
r1 = 2*t-2*r+2;
r2 = min(r1+t, 2*t);
num = r2-r1+1;
syndrome_array(1: num) = syndrome(r1:r2);
delta = syndrome_array*lambda';
lambda0 = lambda;
lambda = gamma*lambda-delta*b2(2:t+2);
if((delta~= zero) && (k>=0))
b2(3)=zero;
b2(4:3+t) = lambda0(1:t);
gamma = delta;
k = -k;
else
b2(3:3+t) = b2(1:t+1);
gamma = gamma;
k=k+2;
end
end;
5)
%massiv v obratnom poradke, tak kak alfa massiv mi zapisivali v obratnom
inverse_tb = gf(zeros(1, t+1), m);
for i=1:t+1,
inverse_tb(i) = alpha^(-i+1);
end;
6)
%Ї®ЁбЄ —ЁҐ /chien's search
lambda_v = zero;
accu_tb=gf(ones(1, t+1), m);
for i=1:n,
lambda_v=lambda*accu_tb';
accu_tb = accu_tb.*inverse_tb;
if(lambda_v==zero)
error(1,n-i+1)=1;
else
error(1,n-i+1)=0;
end
end