list_G = [0 0; 1 0; 1 1; 0 1];
list_IQ = [cos(pi/4)+1i*sin(pi/4); cos(3*pi/4)+1i*sin(3*pi/4); cos(5*pi/4)+1i*sin(5*pi/4); cos(7*pi/4)+1i*sin(7*pi/4)];
r = 1/3; msglen = 5400; TIMES = 20; EbNo = [2,3,4];
r = 1/2; msglen = 7200; TIMES = 3; EbNo = [2];
r = 3/5; msglen = 9720; TIMES = 3; EbNo = [-0.5];
r = 2/3; msglen = 10800; TIMES = 3; EbNo = [0 0.5];
r = 3/4; msglen = 11880; TIMES = 2; EbNo = [2 3];
r = 4/5; msglen = 12600; TIMES = 2; EbNo = [2.5 3.5];
r = 5/6; msglen = 13320; TIMES = 2; EbNo = [2.5 3.5];
r = 8/9; msglen = 14400; TIMES = 2; EbNo = [3.5 4.5];
Hchk = DVBS2LDPC_H_short(r); [Hrow, Hcol] = find(Hchk ~= 0);
msg = randi([0,1], 1, msglen);
Tx = DVBS2LDPC_short(msg, r);
if Tx(2*(i-1)+1:2*(i-1)+2) == [0 0]
elseif Tx(2*(i-1)+1:2*(i-1)+2) == [1 0]
elseif Tx(2*(i-1)+1:2*(i-1)+2) == [1 1]
No = Es./((10.^(EbNo/10))*log2(4));
h = sqrt(K/(K+1)) + sqrt(1/(K+1))*(1/sqrt(2))*(randn(size(Tx4)) + 1j*randn(size(Tx4)));
AWGN = sqrt(No(jj)/2) * (randn(size(Tx4)) + 1j*randn(size(Tx4)));
ric_Rx_noise = ric_Tx + AWGN;
ric_Rx = ric_Rx_noise ./ h;
temp = abs(list_IQ - ric_Rx(i));
Rx4 = [Rx4, list_G(idx,:)];
U = zeros(1,16200); count = 0;
U(2*(i-1)+1) = -(1/No(jj))*(real(ric_Rx(i))-(1/sqrt(2)))^2 + (1/No(jj))*(real(ric_Rx(i))-(-1/sqrt(2)))^2;
U(2*(i-1)+2) = -(1/No(jj))*(imag(ric_Rx(i))-(1/sqrt(2)))^2 + (1/No(jj))*(imag(ric_Rx(i))-(-1/sqrt(2)))^2;
V_msg = [transpose(Hcol); transpose(Hrow)];
V_msg(3,i) = U(V_msg(1,i));
while any(chk) && count < 50 && sum(chk==1)>=15
for i = 1:length(U)-msglen
tempC = [tempC, V_msg(:,j)];
temp = tempC(3,:); temp(:,j) = [];
C_re = [C_re, [tempC(2,j);tempC(1,j);temp]];
tempC = [tempC, C_re(:,j)];
temp = tempC(3,:); temp(:,j) = [];
if V_msg(1,n) == tempC(2,j) && V_msg(2,n) == tempC(1,j)
V_msg(3,n) = U(V_msg(1,n)) + temp;
list = [list, V_msg(:,j)];
TEMP = temp(3) + list(3);
list = [list, V_msg(:,j)];
TEMP = temp(3) + list(3);
[number,BER] = biterr(Tx(1:msglen),Rx4(1:msglen));
CN = [CN; r, TOT, EbNo(jj), count, number, sum(chk==1)];
CN = [CN; r, TOT, EbNo(jj), count, 0, 0];