MATLAB Implementation
MATLAB supports convolutional codes. For example the encoder shown on Img. 1 can be implemented as follows:
G1 = 7;% octal 7 corresponds to binary 111 n1 = m1 + m0 + m-1 G2 = 3;% octal 3 corresponds to binary 011 n1 = m0 + m-1 G3 = 5;% octal 5 corresponds to binary 101 n1 = m1 + m-1 constLen = 3; % Constraint length % Create the trellis that represents the convolutional code convCodeTrellis = poly2trellis(constLen, ); uncodedWord = ; codedWord1 = convenc(uncodedWord, convCodeTrellis) uncodedWord = ; codedWord2 = convenc(uncodedWord, convCodeTrellis)The output is the following:
codedWord1 =
1 0 1codedWord2 =
1 0 1 1 1 0 1 1 1 0 0 0The bits of the first output stream are at positions 1,4,7,...,3k+1,... in output vector codedWord, respectively second stream at positions 2,5,...,3k+2,... and the third 3,6,...,3k,...
Initial state is by default initialized by all zeros.
Read more about this topic: Convolutional Code