%%demo of LFM pulse radar
%==================================================================
function LFM_radar(T,B,Rmin,Rmax,R,RCS)
if nargin==0
T=66.6e-6; %pulse duration 66.66us
B=200e6; %chirp frequency modulation bandwidth 30MHz
Rmin=3e8*T/2;
Rmax=50000; %range bin
R1=10500;
R2=15000;
R3=20000;
R4=25008;
R5=39000;
end
%==================================================================
%%Parameter
C=3e8; %propagation speed
K=B/T; %chirp slope
Rwid=Rmax-Rmin; %receive window in meter 接收窗口,AD采样
Twid=2*Rwid/C; %receive window in second 接收窗口时间
Fs=2*B;
Ts=1/Fs; %sampling frequency and sampling spacing
Nwid=ceil(Twid/Ts); %接收窗口采样次数, 返回大于或者等于指定表达式的最小整数
%==================================================================
%%Gnerate the echo
t=linspace(2*Rmin/C,2*Rmax/C,Nwid); %10km:66.6us 50km:333us 一个脉冲周期时间,基于发射脉冲0时刻而言,但取值范围为最近目标时间至最远距离目标时间
td1=t-2*R1/C; %距离为R的目标回波时间
td2=t-2*R2/C; %距离为R的目标回波时间
td3=t-2*R3/C; %距离为R的目标回波时间
td4=t-2*R4/C; %距离为R的目标回波时间
td5=t-2*R5/C; %距离为R的目标回波时间
Srt1=exp(j*pi*K*td1.^2).*(abs(td1)<T/2);
Srt2=exp(j*pi*K*td2.^2).*(abs(td2)<T/2);
Srt3=exp(j*pi*K*td3.^2).*(abs(td3)<T/2);
Srt4=exp(j*pi*K*td4.^2).*(abs(td4)<T/2);
Srt5=exp(j*pi*K*td5.^2).*(abs(td5)<T/2);
Srt=Srt1+Srt2+Srt3+Srt4+Srt5;
%=======================加窗处理===========================================
win_hann = hann(length(t));
win_rec= rectwin(length(t)) %矩形窗函数
win_bar = bartlett(length(t))%三角窗
% win_han = hanning(length(t1)) %汉宁窗
win_ham = hamming(length(t)) %汉明窗
win_bm = blackman(length(t))%blackman窗
Srt_hann= Srt.*win_hann';
Srt_rec= Srt.*win_rec';
Srt_bar= Srt.*win_bar';
Srt_ham= Srt.*win_ham';
Srt_bm= Srt.*win_bm';
figure;
t1=linspace(0,262143,262144);
plot(t,win_hann,'-r',t,win_rec,'-g',t,win_bar,'-b',t,win_ham,'-c',t,win_bm,'-y');
legend('hann','rec','bar','ham','bm');
title('不同窗函数时域波形');
%==================================================================
%%匹配滤波器
Nfft=2^nextpow2(Nwid+Nwid-1); %number needed to compute linear
Srw_hann=fft(Srt_hann,Nfft); %fft of radar echo 返回 Nfft 点 DFT
Srw_rec=fft(Srt_rec,Nfft);
Srw_bar=fft(Srt_bar,Nfft);
Srw_ham=fft(Srt_ham,Nfft);
Srw_bm=fft(Srt_bm,Nfft);
Nchirp=ceil(T/Ts); %pulse duration in number
t0=linspace(-T/2,T/2,Nchirp);
St=exp(j*pi*K*t0.^2); %chirp signal
Sw=fft(St,Nfft); %fft of chirp signal
figure;
subplot(2,1,1)
plot(t0*1e6,real(St));axis tight;
xlabel('Time in u sec');ylabel('Amplitude')
title('发射基带信号');
subplot(2,1,2)
freq=linspace(-Fs/1,Fs/1,Nchirp);
plot(freq*1e-6,fftshift(abs(fft(St))));%fftshift的操作是将fft结果以fs/2为中心左右互换
title('基带信号幅度频谱');
xlabel('Frequent in Mhz');
grid on;axis tight;
%
Sot_hann=fftshift(ifft(Srw_hann.*conj(Sw))); %signal after pulse compression conj返回Sw共轭复数
Sot_rec=fftshift(ifft(Srw_rec.*conj(Sw))); %signal after pulse compression conj返回Sw共轭复数
Sot_bar=fftshift(ifft(Srw_bar.*conj(Sw))); %signal after pulse compression conj返回Sw共轭复数
Sot_ham=fftshift(ifft(Srw_ham.*conj(Sw))); %signal after pulse compression conj返回Sw共轭复数
Sot_bm=fftshift(ifft(Srw_bm.*conj(Sw))); %signal after pulse compression conj返回Sw共轭复数
% figure
% subplot(211)
% t1=linspace(0,262143,262144);
% plot(t1,abs(Sot1));axis tight;
% title('匹配滤波时域信号');
% subplot(212)
% plot(t1,abs(Sot));axis tight;
% title('匹配滤波频域信号');
%========================================================
N0=Nfft/2-Nchirp/2;
Z_hann=abs(Sot_hann(N0:N0+Nwid-1));
Z_hann=Z_hann/max(Z_hann);
Z_hann=20*log10(Z_hann+1e-6);
Z_rec=abs(Sot_rec(N0:N0+Nwid-1));
Z_rec=Z_rec/max(Z_rec);
Z_rec=20*log10(Z_rec+1e-6);
Z_bar=abs(Sot_bar(N0:N0+Nwid-1));
Z_bar=Z_bar/max(Z_bar);
Z_bar=20*log10(Z_bar+1e-6);
Z_ham=abs(Sot_ham(N0:N0+Nwid-1));
Z_ham=Z_ham/max(Z_ham);
Z_ham=20*log10(Z_ham+1e-6);
Z_bm=abs(Sot_bm(N0:N0+Nwid-1));
Z_bm=Z_bm/max(Z_bm);
Z_bm=20*log10(Z_bm+1e-6);
figure
subplot(311)
plot(t*1e6,Srt_rec);axis tight;
xlabel('Time in u sec');ylabel('Amplitude')
title('Radar echo with rectangle window but without compression');
subplot(312)
plot(t*C/2,Z_rec)
axis([0,50000,-80,0]);
xlabel('Range in meters');ylabel('Amplitude in dB')
title('Radar echo with rectangle window and compression');
subplot(313)
plot(t*C/2,Z_bm)
axis([0,50000,-80,0]);
xlabel('Range in meters');ylabel('Amplitude in dB')
title('Radar echo with black window and compression');
%以矩形窗为参考,同一个窗口对比不同窗
figure;
plot(t*C/2,Z_hann,'-r',t*C/2,Z_rec,'-g',t*C/2,Z_bar,'-b',t*C/2,Z_ham,'-c',t*C/2,Z_bm,'-y');
axis([14000,16000,-120,0]);
xlabel('Range in meters');ylabel('Amplitude in dB')
title('同一目标使用不同窗函数截断和脉压波形');
legend('hann','rec','bar','ham','bm');
%==================================================================
评论5