0

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);
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
Naveen
  • 5
  • 3

1 Answers1

0

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)));
David
  • 8,449
  • 1
  • 22
  • 32
  • Thanks it worked. Actually i am trying to build a turbo encoder. It encodes the msg using 2 parallel convolution encoders. Out of which one encoder encodes the msg after the msg is interleaved. Hence i was using randperm() function. – Naveen Oct 13 '14 at 10:28