LDPC Code simulation with soft decoding
Show older comments
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);
end
% Calculate WER for the current SNR
WER(snr_idx) = numberOfWordErrors / Nstop;
end
% Plot the WER vs SNR graph
figure;
semilogy(SNR_dB, WER, 'b-o');
xlabel('SNR in E_b/N_0 in dB');
ylabel('WER');
title('Word Error Rate vs. SNR for DVB-S.2 LDPC Code');
grid on;
But Result is..

Like that.. So I wondered
Accepted Answer
More Answers (0)
Categories
Find more on PHY Components in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!