Clear Filters
Clear Filters

LDPC Code simulation with soft decoding

19 views (last 30 days)
Hi. I'm trying to create an LDPC code simulation for learning.
The code I made earlier is as follows.
% Define DVB-S.2 LDPC code parameters
dvbS2Rate = 1/2; % Code rate for demonstration
dvbS2ldpc = dvbs2ldpc(dvbS2Rate); % Get the
LDPC object for DVB-S.2
numInfoBits = size(dvbS2ldpc, 2) - size(dvbS2ldpc, 1); % Number of information bits
% Set up simulation parameters
SNR_dB = 1:10; % SNR range from 1 to 10 dB
Nstop = 1000; % Number of frames to simulate
WER = zeros(1, length(SNR_dB)); % Pre-allocate WER for each SNR value
% Create LDPC encoder and decoder objects
ldpcEncoder = comm.LDPCEncoder('ParityCheckMatrix', dvbS2ldpc);
ldpcDecoder = comm.LDPCDecoder('ParityCheckMatrix', dvbS2ldpc, 'DecisionMethod', 'Soft decision');
% Simulation loop over SNR values
for snr_idx = 1:length(SNR_dB)
% Convert SNR from dB to linear scale for noise variance
SNR_linear = 10^(SNR_dB(snr_idx) / 10);
noiseVar = 1 / (2 * SNR_linear * (1/dvbS2Rate));
% Create AWGN channel object
awgnChannel = comm.AWGNChannel('NoiseMethod', 'Variance', 'Variance', noiseVar);
% Initialize error counters
numberOfBitErrors = 0;
numberOfWordErrors = 0;
for frame = 1:Nstop
% Generate random information bits
infoBits = logical(randi([0 1], numInfoBits, 1));
% LDPC encoding
encodedBits = ldpcEncoder(infoBits);
% BPSK Modulation
modulatedSignal = 2 * double(encodedBits) - 1;
% Pass through AWGN Channel
receivedSignal = awgnChannel(modulatedSignal);
% BPSK Demodulation
receivedBits = receivedSignal < 0;
% LDPC Decoding
decodedBits = ldpcDecoder(double(receivedBits));
% Calculate the number of bit errors
bitErrors = sum(infoBits ~= logical(decodedBits));
numberOfBitErrors = numberOfBitErrors + bitErrors;
numberOfWordErrors = numberOfWordErrors + (bitErrors > 0);
% Calculate WER for the current SNR
WER(snr_idx) = numberOfWordErrors / Nstop;
% Plot the WER vs SNR graph
semilogy(SNR_dB, WER, 'b-o');
xlabel('SNR in E_b/N_0 in dB');
title('Word Error Rate vs. SNR for DVB-S.2 LDPC Code');
grid on;
But Result is..
Like that.. So I wondered
  1 Comment
Jongmin on 15 Feb 2024
The Ideal result is this(It is hard decision result when I run that code)

Sign in to comment.

Accepted Answer

Jaswanth on 8 May 2024
Hi Jongmin,
In your LDPC code simulation for a DVB-S.2 setup, the key issue lies in the input format expected by the decoder. Your current approach uses binary bits, whereas the decoder requires Log-Likelihood Ratios (LLRs). To resolve this, you need to modify the demodulation phase to calculate LLRs from the received signals, considering the noise variance.
Please refer to the following response given by a MathWorks Staff member for potentially helpful information.
Also, it is advised in MathWorks documentation to use ldpcEncode over comm.LDPCEncoder, which will be discontinued in future updates. Please refer to following MathWorks documentation to learn more about ldpcEncode:
I hope the information provided above is helpful in accomplishing your task.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!