MATLAB Answers

Reed Solomon encoding/decoding for binary data

조회 수: 10(최근 30일)
Das Siddharth
Das Siddharth 2021년 6월 13일
댓글: Das Siddharth 2021년 6월 16일
I want to encode a binary data with the rsenc. It does the work but it generates random integer parities appenended in the end of the data vector. And when I try to manipulate it with adding random binary values and then pass it through the decoder all the results are messed up. I do get the final result correctly but the rest of the properties are all messed up. Here's one small example of what I did.
message_in_bin_enc = rsenc(message_in_bin_gf,n,k); % example message is [0 0 1] as a galois field.
bin_Rs_enc = message_in_bin_enc;
binRandom = randi([0 1],1,4);
bin_Rs_enc (1,4)= binRandom(1,1);
bin_Rs_enc (1,5)= binRandom(1,2);
bin_Rs_enc (1,6)= binRandom(1,3);
bin_Rs_enc (1,7)= binRandom(1,4);
%So here I tried to manipulate the parity bits with my very own random
%binary bits cause I need the entire data as a binary stream.
% Let's say now the message looks something like [0 0 1 0 0 0 1] assuming
% its a (7,3) RS code.
%Then once it passes through my circuit which (can)randomly flips the
%message bits. e.g : [0 1 0 0 0 0 0] (error)
error = gf(bin_Rs_enc_1,m); % bin_Rs_enc_1 is when it passes through the ciruit and error in introduced.
[corrected_message,sheesh] = rsdec(error,n,k);
%Now if I decode all the results are butchered up for some odd reason tho I
%get the correct final ans.
Please guide me through this. Thank you in advance.

채택된 답변

Akira Agata
Akira Agata 2021년 6월 14일
Since RS system object has 'BitInput' option, I would recommend using comm.RSEncoder rather than rsenc if you want to evaluate FEC performance for binary sequence. The following is a simple example:
% RS(N,K)
N = 7;
K = 3;
% Create RS(7,3) encoder/decoder object
rsEnc = comm.RSEncoder(...
'BitInput', true,...
'CodewordLength', N,...
'MessageLength', K);
rsDec = comm.RSDecoder(...
'BitInput', true,...
'CodewordLength', N,...
'MessageLength', K);
% Since each symbol of RS(7,3) is element of GF(2^3), RS(7,3) encodes every
% 9 bits (= 3 x 3) and generates RS code word of 21 bits (= 3 x 7) length
% Encode 9 binary data bits and create 21 bits code word
rng('default'); % for reproducability
tx_bin = randi([0 1],9,1);
tx_enc_bin = rsEnc(tx_bin);
% For example, add 1 error at the 3rd bit
rx_bin = tx_enc_bin;
rx_bin(3) = 1;
% Decode the received bits
rx_dec_bin = rsDec(rx_bin);
Just in case, let's confirm that the error was corrected:
>> isequal(tx_bin, rx_dec_bin)
ans =
  댓글 수: 3
Das Siddharth
Das Siddharth 2021년 6월 16일
Thank you so much for finding the time to explain this to me. I really appreciate this.

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by