Files
matlab/ofdm/fdet.m
T
jens bddaaee2d5 - auto compensate cyclic prefix
git-svn-id: http://moon:8086/svn/matlab/trunk@25 801c6759-fa7c-4059-a304-17956f83a07c
2015-04-05 14:07:25 +00:00

25 lines
665 B
Matlab

function [omega, err, dmod, omega_coarse, omega_est] = fdet(x, N, Ng, off, omega_min, omega_step, omega_max)
%
K = fix((length(x)-Ng)/(N+Ng))-1;
% Initial guess
omega_coarse = fdet_coarse(x, N, omega_min, omega_step, omega_max);
phi_est = 0;
omega_est = omega_coarse;
for k=1:K
omega(k) = omega_est;
xp = x((k-1)*(N+Ng)+off+1:k*(N+Ng)+off);
x_est = exp(-j*(2*pi*omega_est*(0:N-1)' + phi_est));
iq = xp(Ng+1:N+Ng).*x_est;
dmod(k) = sum(iq);
phi = angle(dmod(k));
omega_f = phi/N/(2*pi);
err(k) = omega_f;
omega_est = omega_est + omega_f;
dphi_est = 2*pi*mod(omega_est*N, 1);
phi_est = mod(phi_est + dphi_est, 2*pi);
end;