40 lines
807 B
Matlab
40 lines
807 B
Matlab
clc; clear;
|
|
|
|
configure_parameters;
|
|
global s_T s_R c
|
|
|
|
% 频域上的匹配滤波
|
|
s_T_fft = fft(s_T);
|
|
s_R_fft = fft(s_R);
|
|
s_R_fft_conj = conj(s_R_fft);
|
|
|
|
matched_filter = ifft(s_T_fft .* s_R_fft_conj);
|
|
[~, peak] = max(matched_filter);
|
|
t_delay = 1 - peak / length(matched_filter);
|
|
d = (c * t_delay) / 2;
|
|
|
|
fprintf("r = %f, predict d = %f\n", r_0, d);
|
|
fprintf("eps = %f\n", abs(r_0 - d));
|
|
|
|
figure(1);
|
|
subplot(311);
|
|
plot(freqs, abs(s_T_fft));
|
|
title("Chirp signal");
|
|
subplot(312);
|
|
plot(freqs, abs(s_R_fft));
|
|
title("Received Chirp signal");
|
|
subplot(313);
|
|
plot(freqs, abs(s_T_fft .* s_R_fft_conj));
|
|
title("Matcher filter");
|
|
|
|
figure(2);
|
|
subplot(311);
|
|
plot(t, s_T);
|
|
title("Chirp signal");
|
|
subplot(312);
|
|
plot(t, s_R);
|
|
title("Received Chirp signal");
|
|
subplot(313);
|
|
plot(t, matched_filter);
|
|
title("After matched filter");
|