what is the problem in this convolutional code

2 visualizaciones (últimos 30 días)
tamim
tamim el 21 de Oct. de 2022
Respondida: Jan el 21 de Oct. de 2022
THE CODE:
% rate 1/2 convolutional encoder
% define trellis
trellis = poly2trellis(7,[111 111]);
% define input and output
x = randi([0 1]);
y = convenc(x,trellis);
% define generator polynomials
g1 = [1 0 1 0 1 1 1 0];
g2 = [1 1 1 0 1 1 0 1];
% encode
y1 = mod(conv(y,g1),2);
y2 = mod(conv(y,g2),2);
% interleave
z = [y1;y2];
z = z(:)';
% modulate
M = 4;
k = log2(M);
y_tx = bi2de(reshape(z,k,length(z)/k).','left-msb');
% plot constellation
scatterplot(y_tx,1,0,'k*');
axis([-5 5 -5 5]);
% add noise
EbNo = 10;
snr = 10;
y_rx = awgn(y_tx,snr,'measured');
% demodulate
z_rx = de2bi(y_rx,k,'left-msb');
% de-interleave
y1_hat = z_rx(1:2:end);
y2_hat = z_rx(2:2:end);
% decode
tblen = 15;
y_hat = vitdec(y1_hat,trellis,tblen,'trunc','hard');
% plot BER
ber = berawgn(EbNo,'psk',M,'nondiff');
semilogy(EbNo,ber,'k*');
hold on;
ber = berawgn(EbNo,'psk',M,'nondiff');
semilogy(EbNo,ber,'ko');
legend('Theoretical BER','Empirical BER');
xlabel('Eb/No (dB)');
ylabel('Bit Error Rate');
THE ERROR:
Error using vitdec
Length of the input code vector must be a multiple of the number of bits in an
input symbol.
Error in test2 (line 67)
y_hat = vitdec(y1_hat,trellis,tblen,'trunc','hard');
WHAT DOES IT MEAN?

Respuestas (1)

Jan
Jan el 21 de Oct. de 2022
There is another problem before:
% rate 1/2 convolutional encoder
% define trellis
trellis = poly2trellis(7,[111 111]);
% define input and output
x = randi([0 1]);
y = convenc(x,trellis);
% define generator polynomials
g1 = [1 0 1 0 1 1 1 0];
g2 = [1 1 1 0 1 1 0 1];
% encode
y1 = mod(conv(y,g1),2);
y2 = mod(conv(y,g2),2);
% interleave
z = [y1;y2];
z = z(:)';
% modulate
M = 4;
k = log2(M);
y_tx = bi2de(reshape(z,k,length(z)/k).','left-msb');
% plot constellation
scatterplot(y_tx,1,0,'k*');
axis([-5 5 -5 5]);
% add noise
EbNo = 10;
snr = 10;
y_rx = awgn(y_tx,snr,'measured');
% demodulate
z_rx = de2bi(y_rx,k,'left-msb');
Error using de2bi
Input must contain only finite real nonnegative integers.

Categorías

Más información sobre Error Detection and Correction en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by