Add experiment

This commit is contained in:
Ksyer
2024-05-09 16:48:29 +08:00
parent 06b3aa1a6d
commit d7b4d9beb2
7 changed files with 173 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
N = 1e3 + 1;
f_c = 1e6;
t = linspace(0, pi / f_c, N);
f_s = 1 / N;
freqs = (0:N-1) / f_s;
x = exp(-1j * 2 * pi * f_c * t);
subplot(211);
plot(t, imag(x));
title("x(t) = sin(t)");
xlabel("t");
ylabel("x(t)");
x_fft = abs(fft(imag(x)));
subplot(212);
plot(t, x_fft);
title("X(f) = fft(x(t))");
xlabel("f");
ylabel("X(f)");
+17
View File
@@ -0,0 +1,17 @@
clc; clear;
configure_parameters;
global s_T s_R
compressed_signal = conv(s_R, fliplr(s_T), 'same');
figure(1);
subplot(311);
plot(t, s_T);
title("Chirp signal");
subplot(312);
plot(t, s_R);
title("Received Chirp signal");
subplot(313);
plot(t, compressed_signal);
title("Matcher filter");
@@ -0,0 +1,21 @@
global f_s T_r simu_time t start_freq end_freq c len r_0 freqs s_T s_R
f_s = 1e4;
T_r = 1 / f_s;
simu_time = 1;
t = linspace(0, simu_time, f_s);
start_freq = 0;
end_freq = 1e7;
c = 3e8;
r_0 = 8e6;
s_T = chirp(t, start_freq, simu_time, end_freq, 'linear') * 10;
len = length(s_T);
freqs = linspace(-f_s / 2, f_s / 2, len);
s_R = zeros(size(s_T));
delay = 2 * r_0 / c;
delay_samples = round(delay * len) + 1;
s_R(delay_samples:len) = 0.8 * s_T(1:len-delay_samples + 1);
s_R = awgn(s_R, 1);
+39
View File
@@ -0,0 +1,39 @@
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");
+24
View File
@@ -0,0 +1,24 @@
clc; clear;
configure_parameters;
global s_T s_R c
% 时域上的匹配滤波
matched_filter = conv(s_R, fliplr(s_T), 'same');
[~, peak] = max(matched_filter);
t_delay = peak / length(matched_filter) - 0.5;
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(t, s_T);
title("Chirp signal");
subplot(312);
plot(t, s_R);
title("Received Chirp signal");
subplot(313);
plot(t, matched_filter);
title("Matcher filter");