summaryrefslogtreecommitdiff
path: root/gnuradio-examples/python/ofdm/ofdm_sync.m
blob: d5df42137325a8cd1255e2d698de35ac7be4078c (plain)
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
%

function [theta, g, g1, k, h] = ofdm_sync(signal,SNR,FFTSIZE,CPLEN)

  rho = SNR/(SNR+1);

  d = abs(signal).^2;
  g = [ zeros(1,FFTSIZE) signal(1:max(size(signal))-FFTSIZE) ];
  g1 = conj(g);
  f = abs(g).^2;
  c = d + f;
  moving_sum_taps = rho/2 * ones(1,CPLEN);
  b = conv(c,moving_sum_taps);
  b = b(1:max(size(signal)));
  %b = b(CPLEN:max(size(b)));
  
  k = g1 .* signal;

  moving_sum_taps2 = ones(1, CPLEN);
  h = conv(k,moving_sum_taps2);
  h = h(1:max(size(signal)));
  %h = h(CPLEN:max(size(h)));
  
  a = abs(h);
  
  theta = a-b;

endfunction