%%%%%%%%%%%%%%%%%%%%%%%%连续波雷达对称三角波信号%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
clear all;
close all;
%%%%%% 参数设置 %%%%%%%
c = 3e8;
f0 = 10e9;
lambda = c/f0;
B = 10e6;
T0 = 1e-4; %%单独正扫频周期
k = B/T0;
fs = 25e6;
%%%%%% 产生发射信号 %%%%%%%
N0 = fs*T0;
t_up = linspace(0, T0, N0);
t_all = linspace(0, 2*T0, 2*N0);
mu_up = f0 + 1/2 * k * t_up; %上扫频
mu_down= mu_up(length(mu_up) : -1 :1); %下扫频
mu_all = [mu_up, mu_down]; %整个周期
St_up = cos(1* 2 * pi * mu_up .* t_up);
St_all = cos(1 * 2 * pi * mu_all .* t_all);
figure(1)
plot(t_up, St_up);grid on;
axis([0,T0,-1,1])
title('上扫频线性调频信号')
figure(2)
plot(t_all, St_all)
xlabel('时间/s');ylabel('幅度/v');grid on;
title('线性调频发射信号')
axis([0,2*T0, -1,1])
%%%%%% 产生回波信号 %%%%%%%
R = 1500; %目标距离
V = 1*300; %目标速度
tau = 2*R / c;
tau_num = fix(tau*fs);
Fd = 2*V / lambda;
mur_all = circshift(mu_all,[0,tau_num]);
tr_all = circshift(t_all,[0,tau_num]);
Sr_all = cos(1 * 2 * pi * mur_all .* tr_all) .* cos(2*pi*Fd*tr_all) -...
sin(1 * 2 * pi * mur_all .* tr_all) .* sin(2*pi*Fd*tr_all);
figure(3)
plot(t_all, real(Sr_all))
xlabel('时间/s');ylabel('幅度/v');grid on;
title('回波信号')
axis([0,2*T0, -1,1])
%%%%%% 混频处理 %%%%%%%
Sb0 = (Sr_all .* St_all); %混频
SNR = -10;
Sb1 = awgn(Sb0, SNR, 'measured'); %差拍加噪声
freq_axis = linspace(-fs/2, fs/2, 2*N0);
fp = 1.1 * B;
hlpf = fir1(256, 2 * fp / fs); %低通滤波器脉冲响应
Sb = filter(hlpf,1,Sb1); %低通滤波后信号
Sb_Freq = abs(fftshift(fft(real(Sb)))); %差拍信号幅频响应
figure(4)
%subplot(211)
plot(t_all, Sb0)
xlabel('时间/s');ylabel('幅度/v');grid on;
title('差拍信号波形图')
axis([0,2*T0, -1,1])
% subplot(212)
% plot(freq_axis, Sb_Freq)
% xlabel('频率/Hz');ylabel('幅度/v');grid on;
% title('差拍信号频谱')
%%%%%%%%%%%%CFAR%%%%%%%%%%%%%%%%%
Pfa = 1e-8;
M = 24;
%K0 = (1/Pfa)^(1/M) - 1;
[Sb_Freq_Cfar, Gate] = CfarProcess(Sb_Freq,M,Pfa);
figure(5)
subplot(211)
plot(freq_axis, Sb_Freq)
hold on;
plot(freq_axis, Gate);grid on;
%axis([0, 1.5e6, 0, 1000])
title('差拍信号及对应门限值')
subplot(212)
plot(freq_axis, Sb_Freq_Cfar)
title('差拍信号CFAR处理后频谱图')
%axis([0, 1.5e6, 0, 1000])
grid on;
%%%%%%%%临时计算%%%%%%%%
f1 = 1.025e6;
f2 = 9.854e5;
R_out = (f1+f2)*2*T0*c/(8*B)
V_out = (f1-f2)*c/4/f0
%%%%%%%%%%%%%%%%%%%%%%%画图专用%%%%%%%%%%%%%%%%%%%%%%%%%%
ft_up = f0 + k * t_up;
ft_down = ft_up(length(ft_up) : -1 :1);
ft_all = [ft_up, ft_down];
fr_all = circshift(ft_all,[0,tau_num]) + Fd;
figure(6)
subplot(211)
plot(t_all, ft_all/1e9)
hold on;
plot(t_all, fr_all/1e9,'--r')
legend('发射信号','回波信号')
xlabel('时间/s');ylabel('频率/GHz');grid on;
axis([0,T0*2,(f0-0.2*B)/1e9, (f0+1.2*B)/1e9])
title('发射/回波信号频率随时间变化')
subplot(212)
plot(t_all, (fr_all-ft_all)/1e9)
axis([0,T0*2,(-0.2*B)/1e9, (0.3*B)/1e9])
xlabel('时间/s');ylabel('频率/GHz');grid on;
title('差拍信号频率随时间变化')
Sb_Freq_up = abs(fftshift(fft(real(Sb(1:N0))))); %上扫频差拍信号幅频响应
Sb_Freq_down = abs(fftshift(fft(real(Sb(N0+1 : 2*N0))))); %下扫频差拍信号幅频响应
[Sb_Freq_Cfar_up, Gate_up] = CfarProcess(Sb_Freq_up,M,Pfa);
[Sb_Freq_Cfar_down, Gate_down] = CfarProcess(Sb_Freq_down,M,Pfa);
freq_axis_updown = linspace(-fs/2, fs/2, N0);
figure(7)
subplot(221)
plot(freq_axis_updown, Sb_Freq_up)
hold on;
plot(freq_axis_updown, Gate_up,'--r');grid on;legend('上扫频差拍','门限值');
axis([0, 1.5e6, 0, 600]);xlabel('频率/Hz');ylabel('幅度/v')
title('上扫频差拍信号及对应门限值')
subplot(223)
plot(freq_axis_updown, Sb_Freq_Cfar_up)
title('上扫频差拍CFAR后');xlabel('频率/Hz');ylabel('幅度/v')
axis([0, 1.5e6, 0, 600])
grid on;
subplot(222)
plot(freq_axis_updown, Sb_Freq_down)
hold on;
plot(freq_axis_updown, Gate_down,'--r');grid on;legend('下扫频差拍','门限值');
axis([0, 1.5e6, 0, 600])
title('下扫频差拍信号及对应门限值');xlabel('频率/Hz');ylabel('幅度/v')
subplot(224)
plot(freq_axis_updown, Sb_Freq_Cfar_down)
title('下扫频差拍CFAR后');xlabel('频率/Hz');ylabel('幅度/v')
axis([0, 1.5e6, 0, 600])
grid on;
figure(8)
plot(t_all, ft_all/1e9)
xlabel('时间/s');ylabel('频率/GHz');grid on;
axis([0,T0*2,(f0-0.2*B)/1e9, (f0+1.2*B)/1e9])
title('发射信号频率随时间变化')
评论15