# Recursive systematic convolutional code (RSC) realization in MATLAB

How can I implement $\rm RSC(2,1,2)$ in MATLAB? Can I use convenc function to build RSC?

The convenc function has 2 arguments: code = convenc(msg,trellis) where trellis=poly2trellis(ConstraintLength,CodeGenerator), and the generator polynomial for this RSC is: $$G=\left(1,\frac{1+D^{2}}{1+D+D^{3}}\right)\quad\text{or}\quad G=\left(1,\frac{5}{7}\right)$$ but for poly2trellis argument CodeGenerator need to be in octal. • Why not implement the state machine directly? It's pretty easy. Hint: you need a current_state vector and a next_state vector. – MBaz Nov 24 '16 at 18:07
• @MBaz If I use convenc function, then for decoder I can use vitdec. This is a part/block of communication system, which need to be tested in MatLab. – Enapolo Nov 25 '16 at 10:57
• Well, your first question is how to implement this system in Matlab. It seems like your question is more specific -- maybe edit your question to clarify what you need? – MBaz Nov 25 '16 at 14:41
• try this: t = poly2trellis( 3, [7 5], 7); code=convenc(input, t); – Young Dec 1 '16 at 11:15
• You can use: poly2trellis(4,[15,5],15) 1+D+D^3 is equivalent with [1 1 0 1] – Mahdi Jan 25 '17 at 11:33

The question is already answered but let me structure it for future readers. From the MATLAB help for the function poly2trellis, here is how you can do it:
TRELLIS = poly2trellis(CONSTRAINTLENGTH, CODEGENERATOR, FEEDBACKCONNECTION)
Hence for the figure in the question: RSC_trellis = poly2trellis( 3, [7 5], 7);
Or, for the other possible RSC encoder, i.e. choosing the lower branch to be fedback: RSC_trellis = poly2trellis( 3, [7 5], 5);