forked from neelabhro/QPSK-Modulation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphase_estimation.m
More file actions
33 lines (32 loc) · 1.11 KB
/
Copy pathphase_estimation.m
File metadata and controls
33 lines (32 loc) · 1.11 KB
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
28
29
30
31
32
33
function phihat = phase_estimation(r, b_train)
% phihat = phase_estimation(r, b_train)
%
% Phase estimator using the training sequence. The phase estimate is
% obtained by minimizing the norm of the difference between the known
% transmitted QPSK-modulated training sequence and the received training
% part. NB! There are other ways of estimating the phase, this is just
% one example.
%
% Input:
% r = received baseband signal
% b_train = the training sequence bits
%
% Output:
% phihat = estimated phase
phihat = 0;
qpsk_b = qpsk(b_train);
r_bits = r(1:length(qpsk_b));% Considering thge bits of the training sequence
e = norm(r_bits-qpsk_b);
%for loop in order to estimate the phase that minimizes the distance
%beetween the QPSK Mapped training sequence and the first bits received in
%the synchronized signal
%Minimizing the distance between the QPSK training sequence and the initial
%bits of the sync signal
for i = -3.1416:0.01:3.1416
rprime = r_bits*exp(-1i*i);
eprime = norm(rprime - qpsk_b);
if(eprime < e)
e = eprime;
phihat = i;
end
end