Convolutional Coding/Decoding Using Matlab Functions

53 Ansichten (letzte 30 Tage)
Jared
Jared am 3 Dez. 2012
Beantwortet: selva ganesh am 13 Sep. 2022
I'm trying to perform convolutional coding/decoding using built in Matlab functions. I'm trying to implement (2,1,3) code.
K=3;
G1=7;
G2=5;
msg=[1 1 0 0 1 0];
trel=poly2trellis(K,[G1 G2]);
coded=convenc(msg,trel);
decoded=vitdec(coded,trel,5*K,'cont','hard');
coded=[1 1 0 1 0 1 1 1 1 1 1 0]
decoded=[0 0 0 0 0 0]
As you would expect, the decoded message should be the same as msg, which it is not. I don't see where I have gone wrong in this simple example.
  2 Kommentare
amjad ali
amjad ali am 14 Nov. 2015
Bearbeitet: Walter Roberson am 14 Nov. 2015
use the following :
K=3;
G1=7;
G2=5;
msg=[1 1 0 0 1 0]
trel=poly2trellis(K,[G1 G2]);
coded=convenc(msg,trel);
tblen = length(msg);
decoded=vitdec(coded,trel,tblen,'trunc','hard')
Amit Kansal
Amit Kansal am 9 Jun. 2021
Bearbeitet: Amit Kansal am 9 Jun. 2021
Amjad's response above is right for the case highlighted.
For the vitdec function, the "cont" (continuous) mode of operation incurs a delay which is why the decoded output has zeros. In the "trunc" (truncated mode), each frame is treated independently and there is no delay incurred in the output. Depending on ones use case (streaming or batch mode), either operation mode may be applicable.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Amit Kansal
Amit Kansal am 24 Jun. 2021
For the vitdec function, the "cont" (continuous) mode of operation incurs a delay which is why the decoded output has zeros.
In the "trunc" (truncated mode), each frame is treated independently and there is no delay incurred in the output.
Therefore, use the following instead:
K = 3;
G1 = 7;
G2 = 5;
msg = [1 1 0 0 1 0]
trel = poly2trellis(K,[G1 G2]);
coded = convenc(msg,trel);
tblen = length(msg);
decoded = vitdec(coded,trel,tblen,'trunc','hard')
For outputs to match the input msg as shown below.
msg =
1 1 0 0 1 0
decoded =
1 1 0 0 1 0
  3 Kommentare
anees rafeh
anees rafeh am 2 Aug. 2021
i am using matlab R2019a
Amit Kansal
Amit Kansal am 2 Aug. 2021
Hello Anees,
Both convenc and vitdec functions are offered with Communications Toolbox. As a result, to be able to use these functions, you would need to have the Communications Toolbox as well on top of base MATLAB.
Hope this helps,
Amit

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Muhammad Haris Khan
Muhammad Haris Khan am 26 Nov. 2019
I'm trying to perform convolutional coding. Kindly share MAtlab code for Part 1. Conv Encoder.
This block encodes the random bit vector u into a (longer) bit vector c. We assume that the convolutional
encoder is not zero-terminated. In this project, we use the following different encoders:
• E1: Rate-1/2 convolutional encoder, generator polynomial G = (1 + D2, 1 + D + D2)
Conv .JPG
  1 Kommentar
Amit Kansal
Amit Kansal am 9 Jun. 2021
You can use
trellis = poly2trellis(3, [5 7]);
convenc(msg, trellis)
to encode a binary msg. In the trellis specification, the [5 7] corespond to the [1+D2, 1+D+D2] polynomials in octal notation.

Melden Sie sich an, um zu kommentieren.


selva ganesh
selva ganesh am 13 Sep. 2022
K=3;
G1=7;
G2=5;
msg=[1 1 0 0 1 0];
trel=poly2trellis(K,[G1 G2]);
coded=convenc(msg,trel);
decoded=vitdec(coded,trel,5*K,'cont','hard');
coded=[1 1 0 1 0 1 1 1 1 1 1 0]
decoded=[0 0 0 0 0 0]

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by