test_bpsk.m

来自「DVB-S2系统仿真代码」· M 代码 · 共 52 行

M
52
字号
clear all; close all; clc;
r=1/2; SNRdB = 1.8-3;

H = dvbs2ldpc(r);
%spy(H)
henc = fec.ldpcenc(H);
hdec = fec.ldpcdec(H);
hdec.DecisionType = 'Soft decision';
hdec.OutputFormat = 'Information part';
hdec.NumIterations = 30;
hdec.DoParityChecks = 'Yes';

% Generate and encode a random binary message
msg = randint(1,henc.NumInfoBits,2);
codeword = encode(henc,msg);

% Construct a QPSK modulator object
modObj = modem.pskmod('M',2,'InputType','Bit');

% Modulate the signal
modulatedsig = modulate(modObj, codeword);

% Noise parameters
sigma = sqrt(10^(-SNRdB/10));

% Transmit signal through AWGN channel
receivedsig = awgn(modulatedsig, SNRdB, 0); % Signal power = 0 dBW

% Visualize received signal
%scatterplot(receivedsig)

% Construct a QPSK demodulator object to compute
% log-likelihood ratios
demodObj = modem.pskdemod(modObj,'DecisionType','LLR', ...
     'NoiseVariance',sigma^2);

% Compute log-likelihood ratios (AWGN channel)
llr = demodulate(demodObj, receivedsig);

% Decode received signal
decodedmsg = decode(hdec, llr);

% Actual number of iterations executed
disp(['Number of iterations executed = ' ...
     num2str(hdec.ActualNumIterations)]);
% Number of parity-checks violated
disp(['Number of parity-checks violated = ' ...
     num2str(sum(hdec.FinalParityChecks))]);
% Compare with original message
disp(['Number of bits incorrectly decoded = ' ...
     num2str(nnz(sign(decodedmsg)-1+2*msg))]);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?