function [ sRx ] = f_time_sync( sTx,sigrx )
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here
%Celociselna
[c,lag] = xcorr(sTx, sigrx);
[~,I] = max(abs(c));
lagDiff = lag(I);
sigrx = circshift(sigrx,lagDiff,2);
sRx=sigrx;


%Subsamplova
g=1;
for k=-0.5:0.02:0.5
sigfr=sig_delay_fft( sigrx, k );
sRx = sigfr(1:length(sTx));
[crt,~] = xcorr(sTx, sRx);
cr(g,:)=[max(abs(crt)) k];
g=g+1;
end
[~,crtki]=max(cr(:,1));
sigfr=sig_delay_fft( sigrx, cr(crtki,2));
fprintf('frac sync= %.4f\n',cr(crtki,2));
sRx = sigfr(1:length(sTx));

end

