0% found this document useful (0 votes)
32 views

All All 'Enter The Constraint Length: ' 'Enter The Message Bits: '

The document describes convolutional encoding and Viterbi decoding. It takes in a constraint length and message bits as input. It performs convolutional encoding on the message bits using the given constraint length to generate an encoded output. It then performs Viterbi decoding on the encoded output using the same convolutional code trellis to recover the original message bits.

Uploaded by

Aniil J Kumaar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

All All 'Enter The Constraint Length: ' 'Enter The Message Bits: '

The document describes convolutional encoding and Viterbi decoding. It takes in a constraint length and message bits as input. It performs convolutional encoding on the message bits using the given constraint length to generate an encoded output. It then performs Viterbi decoding on the encoded output using the same convolutional code trellis to recover the original message bits.

Uploaded by

Aniil J Kumaar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

6.

Convolutional Encoding and Viterbi Decoding


clear all;
close all;
clc;
k=input('enter the constraint length: ')
m=input('enter the message bits: ')
v=zeros(length(m),k)
a=zeros(1,k-1);
for i=1:length(m)
for j=k:-1:2
a(j)=a(j-1);
end
a(1)=m(i);
v(i,1)=a(1);
v(i,2)=xor(a(1),a(3));
v(i,3)=abs(mod(sum(a,2),2));
end
o=v'
encoded_output=reshape(o,1,k*length(m))

trellis=poly2trellis(k,[4 5 7])
trellis_encoded =convenc(m,trellis)

%%DECODING
decode=vitdec(code,trellis,k,'trunc','hard')

%%% OUTPUT%%%
enter the constraint length: 3
k =
3
enter the message bits: [1 1 0 1 1]
m =
1 1 0 1 1
v =
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
o =
1 1 0 1 1
1 1 1 0 1
1 0 0 0 0
encoded_output =
Columns 1 through 12

1 1 1 1 1 0 0 1 0 1 0 0
Columns 13 through 15

1 1 0

trellis =
numInputSymbols: 2
numOutputSymbols: 8
numStates: 4
nextStates: [4x2 double]
outputs: [4x2 double]

trellis_encoded =
Columns 1 through 12
1 1 1 1 1 0 0 1 0 1 0 0

Columns 13 through 15

1 1 0
decode =

1 1 0 1 1

You might also like