# Setting Parity Check Matrix for LDPC channel coding

I am trying to implement the LDPC code for OFDM system, where I input data should be binary of length $$1024$$ and the output coded data of length $$2048$$ (means of rate 1/2).

As known in Matlab integrated function, we build the encoder and decoder, respectively, as:

ldpcEncoder = comm.LDPCEncoder;  %Encoder
ldpcDecoder = comm.LDPCDecoder;  %Decoder

After checking that, I see that parity check matrix is set by default into $$32400$$ x $$64800$$ which means the input data length must be a column of length $$32400$$.

I need the input data to be set manually, for example of length $$1024$$, how can I modify the parity check of the above encoder?

Thank you

• Maybe, you should try to build the ldpc manually using your own parameters. – Zeyad_Zeyad Jul 17 '20 at 12:53
• Matlab doesn't have a default 32400 x 64800 size: you've entered that somewhere before. You're not showing us all of your code! – Marcus Müller Jul 17 '20 at 14:20
• That's all what I entered, I only entered these two commands, and the resulted size is 32400 x 64800. @MarcusMüller – Fatima_Ali Jul 17 '20 at 14:42
• @Fatima_Ali these two lines don't output the size, so that can't be all you've done. Do a clear, then post all lines that you had to type to find out the size. – Marcus Müller Jul 17 '20 at 14:47
• @Fatima_Ali the documentation is clear fr.mathworks.com/help/comm/ref/… Specify 'ParityCheckMatrix' in both encoder and decoder. – AlexTP Jul 17 '20 at 15:47

As specified in documentation, using 'ParityCheckMatrix' you can configure the Parity Check Matrix (PCM) during the constructions of the encoder/decoder objects.

The syntax is encoder = comm.LDPCEncoder('ParityCheckMatrix',pcm) or simply

encoder = comm.LDPCEncoder(pcm);

where pcm is the desired PCM which must be sparse type.

An example for (probably poor performance) 1024x2048 PCM:

pcm = sparse([eye(1024) eye(1024)]);
encoder = comm.LDPCEncoder(pcm);
decoder = comm.LDPCDecoder(pcm);

%data
m = randi([0 1],1024,1);
%encode then decode. Note the convention of the output of comm.LDPCDecoder
y = 1 - decoder(encoder(m));
%error which equals to 0
biterr(y,m)
• Thank you for you help – Fatima_Ali Jul 18 '20 at 9:46
• @Fatima_Ali you are welcome – AlexTP Jul 18 '20 at 10:36