-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathml_bpsk.m
28 lines (26 loc) · 817 Bytes
/
ml_bpsk.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [bitBpsk, snrAvgBpsk] = ml_bpsk(symbolBpsk)
% Function:
% - maximum-likelihood detector for BPSK symbols
%
% InputArg(s):
% - symbolBpsk: BPSK symbol stream
%
% OutputArg(s):
% - bitBpsk: recovered bit stream
% - snrAvgBpsk: average output SNR
%
% Comments:
% - signal space should be 1-d but is actually 2-d due to complex noise
% - does not influence system performance
% - real part positive -> symbol closed to sqrt(p) -> bit 0
% - real part negative -> symbol closed to -sqrt(p) -> bit 1
%
% Author & Date: Yang ([email protected]) - 22 Jan 19
powerNoise = 1;
% compute average received bit power
powerBitAvg = norm(symbolBpsk) ^ 2 / length(symbolBpsk);
% and average output SNR
snrAvgBpsk = powerBitAvg / powerNoise;
% demap to bits
bitBpsk = 1 / 2 * (1 - sign(real(symbolBpsk)));
end