Assuming you have generated an LDPC parity check matrix H and a message m that you want to encode, add noise and decode, here are the steps to encode, add noise and decode a bit vector using LDPC codes in MATLAB:
Import the LDPC encoder method from the Communications Toolbox library by typing ldpcenc = comm.LDPCEncoder(H);. This will create an object that will be used to encode the message with the parity check matrix H.
Encode the message using the ldpcenc object by typing cword = ldpcenc(m);. This will create a codeword cword from the message m that has been encoded using the LDPC parity check matrix H.
Add noise to the cword using a noise generator, e.g., nword = awgn(cword,SNRdB,'measured');, where SNRdB is the signal-to-noise ratio in decibels that you want to simulate the channel to have.
Import the LDPC decoder method from the Communications Toolbox library by typing ldpcdec = comm.LDPCDecoder(H);. This will create an object that will be used to decode the noisy codeword back to the original message.
Decode the noisy codeword using the ldpcdec object by typing rxmsg = ldpcdec(nword);. This will decode the noisy codeword nword back to the original message rxmsg using the LDPC parity check matrix H.
Here is the complete example code:
main.m650 chars27 lines
Note that you will need the Communications Toolbox library to use ldpcenc and ldpcdec methods.
gistlibby LogSnag