Search code examples
matlabencodertelecommunicationforwarderrorcorrection

Turbo Encoder inter-leaver not working


I am trying to create a turbo encoder for my project.

Till now i have created the convolution encoder of 1/2 rate. Now i am having difficulty to apply interleaver. Here is my code. I am not getting output in ilvr. Correct me where i am going incorrect. Thanks in advance

msg = [0 1 0 1 1 1 0 0 1 0 1 0 0 0 1];
t= poly2trellis(3,[6 7]);
[isok,status] = istrellis(t);
code1 = convenc(msg,t);
ilvr = randperm(msg);
code2 = convenc(ilvr,t);

Solution

  • Well, firstly, if your question is about ilvr then why include the rest of the code other than the definition of msg and the line in question?

    Secondly, when I ran this:

    msg = [0 1 0 1 1 1 0 0 1 0 1 0 0 0 1];
    ilvr = randperm(msg);
    

    I got the following error:

    Error using randperm
    Size inputs must be scalar.
    

    So, this means the the input is not what randperm was expecting. Then I typed help randperm, and looked at the help for randperm, so now I understand what randperm does and what inputs it expects. The error is because you gave randperm a vector, but the first input must be an integer.

    I'm not sure what you are trying to do on that line, maybe you are trying to get a random permutation of the elements in msg? Following a hint in the help page, try this:

    ilvr=msg(randperm(numel(msg)));