How come the Bit Error Rate for my Vitrebi soft decoder always returns as 0.5 for all values of SNR?
조회 수: 3 (최근 30일)
이전 댓글 표시
So this is my code in which I'm trying to get the BER for soft decision Vitrebi decoding using BPSK modulation in an AWGN channel with code rate 1/3:
input_size = 400;
terminate_length = 3;
total_input_size = 403;
kin = 1;
n = 3;
v = 3;
total_states = 2^v;
current_state = 0;
SNR = 1:1:12;
% Data generation
data = [randi([0 1], 12, input_size), zeros(12, terminate_length)];
% BPSK Modulation
% Decoder
temp_reg = randn(12, 1209);
trellis_poly = poly2trellis(4, {'x3 + x2 + 1', 'x3 + x + 1', 'x3 + 1'});
for i = 1:length(SNR)
% Add noise
codeword(i,:) = convenc(data(i,:),trellis_poly);
codeword_bpsk(i,:) = codeword(i,:) * 2 -1;
corrupted_codeword(i, :) = sqrt(0.5*(1./SNR(i)))*codeword_bpsk(i, :) + temp_reg(i, :);
decoded(i,:) = vitdec(corrupted_codeword(i, :), trellis_poly, 3, 'term', 'unquant');
BER(i) = biterr(data(i, 1:end-3),decoded(i,3+1:end))/403;
end
The input size is of 400 bits + 3 bits to get back to state 0. I generate therefore 12x403 data bits. I define my trellis polynomial and begin the for loop.
For each value of SNR from 1 - 12, I convolutionally encode the data, I convert it to BPSK and then I add noise. This is done by multiplying a custom variance by the data and adding some noise drawn from the normal distribution.
I then decode this using the corrupted_codeword, my trellis polynomial, the traceback length is 3 as this is the maximum amount of bits needed to return to state 0. Term means it should terminate at state 0 and from examples I saw that MATLAB used 'unquant' for soft decoding. I know you can use 'soft' but that only lets you use positive integers which I don't quite understand as I thought the whole point of soft decoding was that you could economically do it with Vitrebi using any kind of value.
Anyway, I then compute the number of bit errors between the original data and the decoded data, excluding the trailing bits hence the 1:end-3, then divide by the number of bits. However, for every single value of SNR I'm getting a Bit Error Rate of roughly 0.5 which obviously isn't right. I've tried changing the 403 to 400 to account for the missing trailing bits but that makes no difference. If I also try just doing data(i,:) and decoded(i,:) in biterr I still get the same thing. I don't quite get where this is going wrong since I'm using MATLAB's built in functions, also the decoded data looks right since they start and terminate with data corresponding to state 0 but it just doesn't match up with the actual data.
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Error Detection and Correction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!