Documentation Center

  • Trial Software
  • Product Updates

Contents

convenc

Convolutionally encode binary data

Syntax

code = convenc(msg,trellis)
code = convenc(msg,trellis,puncpat)
code = convenc(msg,trellis,...,init_state)
[code,final_state] = convenc(...)

Description

code = convenc(msg,trellis) encodes the binary vector msg using the convolutional encoder whose MATLAB trellis structure is trellis. For details about MATLAB trellis structures, see Trellis Description of a Convolutional Code. Each symbol in msg consists of log2(trellis.numInputSymbols) bits. The vector msg contains one or more symbols. The output vector code contains one or more symbols, each of which consists of log2(trellis.numOutputSymbols) bits.

code = convenc(msg,trellis,puncpat) is the same as the syntax above, except that it specifies a puncture pattern, puncpat, to allow higher rate encoding. puncpat must be a vector of 1s and 0s, where the 0s indicate the punctured bits. puncpat must have a length of at least log2(trellis.numOutputSymbols) bits.

code = convenc(msg,trellis,...,init_state) allows the encoder registers to start at a state specified by init_state. init_state is an integer between 0 and trellis.numStates-1 and must be the last input parameter.

[code,final_state] = convenc(...) encodes the input message and also returns the encoder's state in final_state. final_state has the same format as init_state.

Examples

Encodes five two-bit symbols using a rate 2/3 convolutional code. A schematic of this encoder is on the poly2trellis reference page.

s = RandStream.create('mt19937ar', 'seed',123);
prevStream = RandStream.setGlobalStream(s); % Set stream for repeatability
code1 = convenc(randi([0 1],10,1),...
poly2trellis([5 4],[23 35 0; 0 5 13]));
RandStream.setGlobalStream(prevStream); % Restore default stream

The following syntax defines the encoder's trellis structure explicitly and then uses convenc to encode 10 one-bit symbols. A schematic of this encoder is in Trellis Description of a Convolutional Code.

trel = struct('numInputSymbols',2,'numOutputSymbols',4,...
'numStates',4,'nextStates',[0 2;0 2;1 3;1 3],...
'outputs',[0 3;1 2;3 0;2 1]);
code2 = convenc(randi([0 1],10,1),trel);

The following syntax illustrates how to use the final state and initial state arguments when invoking convenc repeatedly. Notice that [code3; code4] is the same as the earlier example's output, code1.

s = RandStream.create('mt19937ar', 'seed',123);
prevStream = RandStream.setGlobalStream(s); % Set stream for repeatability
trel = poly2trellis([5 4],[23 35 0; 0 5 13]);
msg = randi([0 1],10,1);
% Encode part of msg, recording final state for later use.
[code3,fstate] = convenc(msg(1:6),trel);
% Encode the rest of msg, using state as an input argument.
code4 = convenc(msg(7:10),trel,fstate);
RandStream.setGlobalStream(prevStream); % Restore default stream

Examples

For some commonly used puncture patterns for specific rates and polynomials, see the last three references.

References

[1] Clark, G. C. Jr. and J. Bibb Cain., Error-Correction Coding for Digital Communications, New York, Plenum Press, 1981.

[2] Gitlin, Richard D., Jeremiah F. Hayes, and Stephen B. Weinstein, Data Communications Principles, New York, Plenum, 1992.

[3] Yasuda, Y., et. al., "High rate punctured convolutional codes for soft decision Viterbi decoding," IEEE Transactions on Communications, vol. COM-32, No. 3, pp 315–319, Mar. 1984.

[4] Haccoun, D., and G. Begin, "High-rate punctured convolutional codes for Viterbi and sequential decoding," IEEE Transactions on Communications, vol. 37, No. 11, pp 1113–1125, Nov. 1989.

[5] Begin, G., et.al., "Further results on high-rate punctured convolutional codes for Viterbi and sequential decoding," IEEE Transactions on Communications, vol. 38, No. 11, pp 1922–1928, Nov. 1990.

See Also

| | |

Was this topic helpful?