0

I want to create the Hamming soft decoder using the Euclidean distance (with fonction repmat). I tried to program but it does not work as I want, I do not find the right BER.

Anyone detected the error in my decoder?

% Soft decoding

Matlab Code :

n = 7; k = 4; Rate = k/n;   
G = [1 0 0 0 1 1 0 ; 0 1 0 0 1 0 1 ; 0 0 1 0 0 1 1 ; 0 0 0 1 1 1 1];
Eb_N0 = 0:10;                          
ber = zeros(1,11);          
words = 10000;
for kk = 1:11
    E_N0 = 10^(Eb_N0(kk)/10);           
    sigma = 1/(2*Rate*E/N0);  
    for jj = 1:words
        m = rand(1,4)>1/2; 
        c = mod(m*G,2);     
        x = 2*c-1;                     % Modulated code word
        w = sqrt(sigma)*randn(1,n);    % additive white gaussian noise
        y = x+w ;                      % receive vector
        N = 2^k;
        X = zeros(N,n);
        for yy = 0:N-1
            m = base2dec(dec2bin(yy,k).',2).';
            X(yy+1,:) = x;             % Set of modulated code words
        % Euclid. distance between y and each of the 16 modulated code words x
           dist = sqrt(sum(abs(X - repmat(y,[2^k,1])).^2,2)); 
        end
        [dmin, ind] = min(dist); 
        r = X(ind,:); 
        CodeDecode = r(1:4); %decoded info symbols
       % counting error 
       error = sum(m ~= CodeDecode);
       ber(kk) = ber(kk) + error;

    end  

end

ber = ber/(k*words);
theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0/10))); % theoretical ber uncoded AWGN
figure
semilogy(theoryBer,'b-');
hold on
semilogy(ber,'o-r');
legend('theory - uncoded','Soft Hamming')
title('BER for BPSK in AWGN with Hamming')
xlabel('Eb/N0 ')
ylabel('Ber')
m2016b
  • 534
  • 5
  • 19
  • 1
    Please mention a sample input and expected output. – m7913d Jun 24 '17 at 13:42
  • I do not understand your question well. My problem found in the calculation of the euclidean distance **dist**, I find the same euclidean distance. – m2016b Jun 24 '17 at 14:48
  • 2
    Not everyone is an _Hamming Soft Decoding_ expert. So, the more information you give, the more likely someone is able to assist you with solving your problem. A runnable code including all (example) inputs and desired outputs may help people to understand your problem. See [mcve] and [ask]. – m7913d Jun 24 '17 at 20:05
  • I must normally find a `BER` decreasing and always lower than 1. While I find ber higher than 1 and does not really change. For example i find `ber = 1.9770 1.9970 1.9680 2.0290 2.0240 2.0060 1.9830 1.9500 1.9470 2.0130 2.0240` – m2016b Jun 24 '17 at 23:48

0 Answers0