Calculation of LLR values with variable noise variance

Calculates the LLR values for a given constellation, mapping and noise variance.
1.9K Downloads
Updated 9 Mar 2011

View License

%LLR_DEMOD LLR Demodulator
% H = LLR_DEMOD_MEX(CONSTELLATION, MAPPING, METHOD) constructs
% a LLR demodulator object H for a given constellation, mapping and noise
% variance. The vectors CONSTELLATION and MAPPING are usually generated by
% using MATLAB Modem Modulation Modem.<Type> and contain the complex or
% real constellations points and the bit mapping, but in generall any signal
% constellation and any bit-mapping can be used. METHOD determines whether
% the exact LLR values or the approximations are calculated. (for more information:
% http://www.mathworks.com/help/toolbox/comm/ug/bqwswmc-1.html)
%
% A LLR demodulator object is equipped with one function:
% - CALC_LLR (type "help llr_demod/calc_llr" for detailed help)
%
% Input: CONSTELLATION [1xM]
% MAPPING [1xM]
% Method ['exact', 'approx']
%
% Output: H [1x1]

Important: Before you can start you have to compile the mex-file mex_calc_llr.cpp by executing compile_mex_calc_llr.m. There is a test file and a small example of a simulation framework which will be extended in future updates. The old files can be found in the subdirectory OLD.

#######################################

These are the basic commands lines:

llr_demod_obj = mex_llr_demod(Constellation,Mapping,Methode); % generate object

llr = calc_llr(llr_demod_obj,r,noise_var); % calculate llr values

# New: Noise_var don't have to be a scalar value, but may be a vector of the same length as vector r.
########################################

Small example of a simulation framework:

EbN0 = 5; %dB
M = 16; % 2, 4, 16, 64 .... - QAM
fading = 1; % fading on/off

% get M-QAM constellation and mapping
h_mw = modem.qammod('M',M,'InputType', 'Bit','SymbolOrder','Gray');
constellation = h_mw.Constellation;
mapping = h_mw.SymbolMapping;

% get variance of signal constellation (needed for the calculation of the
% noise variance)
sigma_a2 = sum(abs((constellation - mean(constellation))).^2/length(constellation));

% calculation of the noise variance
EsN0 = 10*log10(10.^(EbN0/10) * log2(M));
sigma_n2 = sigma_a2./(10.^(EsN0./10));

llr_demod_obj = mex_llr_demod(constellation,mapping,'exact'); % generate object

for i = 1:100 % demodulate 100 frames of 1000 M-QAM Symbols

% generate bitstream
u = randi([0 1],1000*log2(M),1);

% do modulation with matlab object
x = modulate(h_mw,u);

% generate fading factors
if fading
H = 1/sqrt(2)*randn(size(x)) + 1i * 1/sqrt(2) * randn(size(x));
else
H = 1;
end

% calculate received signal
r = x.*H + sqrt(0.5*sigma_n2)*randn(size(x)) + 1j * sqrt(0.5*sigma_n2)*randn(size(x));

% do Zero Forcing Equalization
r_hat = r./H;

% do demodulation (with variable NOISE_VAR sigma_n2./abs(H).^2)
llr = calc_llr(llr_demod_obj, r_hat, sigma_n2./abs(H).^2);

end

Cite As

Bernhard Schmidt (2024). Calculation of LLR values with variable noise variance (https://www.mathworks.com/matlabcentral/fileexchange/30110-calculation-of-llr-values-with-variable-noise-variance), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on PHY Components in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.6.0.0

Noise variance doesn't have to be constant anymore. User can set for each symbol a different noise variance.

1.5.0.0

Calculation for approximated llr values added.

1.4.0.0

I simplified the calculation for BPSK constellation. The demodulation with calc_llr is now faster than Mathworks function demodulate.m, even for BPSK modulation. Furthermore I introduced a version number for the m-file. Recent version is 1.0.

1.3.0.0

The calculation of the LLR-values are now done with a mex-function. For higher order modulations it's about three time faster than Mathworks DEMODULATE function.
Old files were put in a subdirectory.

1.1.0.0

Update: New object function included with reduced overhead. There is one example file included too.

1.0.0.0