Add Radar simulation
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
function doppler = get_doppler(s_T, s_R)
|
||||
global T_r delta_t len f_s c f_c velocity max_t slow_len;
|
||||
|
||||
freqs = ((0:len-1) * f_s) / len;
|
||||
|
||||
slow_freqs = ((0:slow_len-1) * (1 / T_r)) / slow_len;
|
||||
range_t_slow = 1:slow_len;
|
||||
|
||||
num_slow = max_t / T_r;
|
||||
s_R_slow = zeros(1, slow_len);
|
||||
k = floor(T_r / delta_t);
|
||||
|
||||
init_idx = 1;
|
||||
while abs(s_R(init_idx)) == 0
|
||||
init_idx = init_idx + 1;
|
||||
end
|
||||
init_idx
|
||||
|
||||
for i = 0: num_slow - 1
|
||||
while abs(s_R(init_idx + i * k)) == 0
|
||||
init_idx = init_idx + 1;
|
||||
end
|
||||
s_R_slow(i + 1) = s_R(init_idx + i * k);
|
||||
end
|
||||
|
||||
s_R_fft = fft(s_R_slow);
|
||||
[~, max_index_s_R] = max(s_R_fft);
|
||||
freq_s_R = slow_freqs(max_index_s_R);
|
||||
|
||||
figure(2);
|
||||
subplot(2,1,1);
|
||||
plot(range_t_slow, abs(s_R_slow));
|
||||
title(sprintf('s_R'));
|
||||
subplot(2,1,2);
|
||||
plot(slow_freqs, abs(s_R_fft));
|
||||
title(sprintf('s_R_fft, freq = %E', freq_s_R));
|
||||
xlabel('频率 (Hz)');
|
||||
|
||||
f_d = 1/T_r - freq_s_R;
|
||||
|
||||
fprintf("s_R_freq = %d\n", max_index_s_R);
|
||||
fprintf("doppler_freq = %E\n\n", f_d);
|
||||
|
||||
fprintf("%E\n", 2 * f_c * velocity / c);
|
||||
|
||||
doppler_v = (c * f_d) / (2 * f_c);
|
||||
|
||||
fprintf("doppler_v: %E\nvelocity: %E\n", doppler_v, velocity);
|
||||
|
||||
doppler = doppler_v;
|
||||
end
|
||||
Reference in New Issue
Block a user