clc
;
clear
all
;
close
all
;
fs = 1e9;
fo = 200e6;
t = 0:1/fs:1023/fs;
tao = 0.3/3e8*
sind
(45);
SNR = 20;
ch1 = awgn(
sin
(2*
pi
*t*fo),SNR) ;
ch2 = awgn(
sin
(2*
pi
*t*fo + 2*
pi
*tao*fo),SNR);
% ch1 = sin(2*pi*t*fo) ;
% ch2 = sin(2*pi*t*fo + 0.5);
pha =
angle
(hilbert(ch2))-
angle
(hilbert(ch1));
figure
()
subplot
211
plot
(t*fs,pha);
subplot
212
plot
(t(1:512)*fs,
abs
(
fft
(ch1(1:512))),
'r--'
);
hold
on;
%FFT提取相位
pha1 =
angle
(
fft
(ch1(1:512)).*
fft
(ch2(1:512)));
figure
()
subplot
211
plot
(t(1:512)*fs,pha1);
subplot
212
plot
(t(1:512)*fs,
abs
(
fft
(ch1(1:512))),
'r--'
);
hold
on;
%apFFT提取相位
win = hanning(512)';
win1 =
conv
(win,win);
win1 = win1/
sum
(win1);
y1 = ch1(1:1023).*win1;
y2 = ch2(1:1023).*win1;
out1 = [0,y1(1:511)]+y1(512:1023);
out2 = [0,y2(1:511)]+y2(512:1023);
pha2 =
angle
(
fft
(out1).*
conj
(
fft
(out2)));
figure
()
subplot
211
plot
(t(1:512)*fs,pha2);
subplot
212
plot
(t(1:512)*fs,
abs
(
fft
(ch1(1:512))),
'r--'
);
hold
on;
[~,pos] =
max
(
abs
(
fft
(ch1(1:512))));
[pha2(pos)
mean
(pha) ;-
pi
+ 2*
pi
*tao*fo 2*
pi
*tao*fo]
theta_est =
asind
((pha2(pos))/2/
pi
/fo/0.3*3e8)+90;
abs
(theta_est-45)