T=200e-6;
D=0.1;
Tp=T*D;
A=rand()*100;
fc=10e9;
C=3e8;
v=rand()*1000;
lemda=C/fc;
Num = 500;
B=6e6;
K=B/T;
Fs=2*B;
Ts=1/Fs;
N=round(T/Ts);
R=rand()*10000;
SNR=-35+rand()*45;
fd=2*v*fc/C;
%发射信号
t_fashe = linspace(0,T/10,N/10);
Stp = exp(1j*pi*K*t_fashe.^2);
ze_fashe=zeros(1,2160);
Stp_fashe=[Stp,ze_fashe];
t_fashe2=linspace(0,T,N);
figure(1);
subplot(211)
plot(t_fashe2*1e6,real(Stp_fashe));
xlabel('时间/us');
ylabel('幅度');
title('线性调频脉冲发射信号时域波形');
grid on;axis tight;
subplot(212)
freq = linspace(-Fs/2,Fs/2,N);
plot(freq*1e-6,fftshift(abs(fft(Stp_fashe))));
xlabel('频率/MHz');
title('线性调频脉冲发射信号频谱');
grid on;axis tight;
%自相关
t_zi = linspace(0,T/10,N/10);
Stp_zi = exp(1j*pi*K*t_zi.^2);
Ht=conj(fliplr(Stp_zi));
St_conv=abs(conv(Ht,Stp_zi));
St_conv_log=10*log10(St_conv);
figure(2);
subplot(111);
plot(St_conv_log);
xlabel('时间/us');
ylabel('幅度/dB');
title('自相关函数');
grid on;axis tight;
%重复周期处理
rep_Number=128;
Stp128=repmat(Stp_fashe,1,rep_Number);
t64 = linspace(0,128*T,128*N);
figure(3);
subplot(111);
plot(t64*1e6,real(Stp128));
xlabel('时间/us');
ylabel('幅度');
title('重复128个周期的发射信号');
grid on;axis tight;
%理想回波信号
t0=2*R/C;
ze_left=zeros(1,round(t0*N/T));
Stp_hui = [ze_left,Stp128];
Stp_hui0=Stp_hui(:,1:307200);
figure(4);
subplot(211)
plot(real(Stp_hui0));
xlabel('时间/us');
ylabel('幅度');
title('理想回波信号时域波形');
grid on;axis tight;
subplot(212)
freq = linspace(-Fs/2,Fs/2,length(Stp_hui0));
plot(freq*1e-6,fftshift(abs(fft(Stp_hui0))));
xlabel('频率/MHz');
title('理想回波信号频域谱');
grid on;axis tight;
%添加噪声
tt=0:T/N:(T*rep_Number-T/N);
Stp_fd=exp(1j*2*pi*fd.*tt);
Stp_fd_huibo=Stp_fd.*Stp_hui0;
noisePower = 1;
sigPower = noisePower .* (10.^(SNR/10));
A = sqrt(2*sigPower);
St_noise = A*Stp_fd_huibo + randn(size(Stp_fd_huibo));
St_noise_real=real(St_noise);
figure(5);
subplot(211);
plot(St_noise_real);
title('脉冲压缩前回波信号时域波形');
grid on;axis tight;
%脉压处理
match_filter=fliplr(Stp);
match_filter=conj(match_filter);
Stp_convolution=conv(match_filter,St_noise);
Stp_convolution_abs=abs(Stp_convolution);
St_convolution_log=10*log10(Stp_convolution_abs);
subplot(212);
plot(St_convolution_log);
title('脉冲压缩后回波信号时域波形');
grid on;axis tight;
%距离门重排
for r=1:rep_Number
for h=1:N
index=(r-1)*N+h;
Stp_rang(h,r)=Stp_convolution(index);
end
end
Stp_rang_real=abs(Stp_rang);
figure(6);
subplot(311);
mesh(1:rep_Number,1:N,Stp_rang_real);
xlabel('距离门');
ylabel('采样点');
title('距离门重排后脉冲压缩信号幅度');
%FFT
for h=1:N
Stp_fft(h,:)=abs(fft(Stp_rang(h,:)));
end
subplot(312);
mesh(1:rep_Number,1:N,Stp_fft);
title('FFT后脉冲压缩信号幅度');
Stp_fft_log=10*log10(Stp_fft);
subplot(313);
mesh(1:rep_Number,1:N,Stp_fft_log);
title('FFT后脉冲压缩信号幅度(取对数)');
%脉冲压缩前距离门重排
for r=1:rep_Number
for h=1:N
index=(r-1)*N+h;
Stp_rang(h,r)=St_noise(index);
end
end
Stp_rang_real=real(Stp_rang);
figure(7);
subplot(211);
mesh(1:rep_Number,1:N,Stp_rang_real);
title('脉冲压缩前距离门重排后信号幅度');
%FFT
for h=1:N
Stp_fft(h,:)=abs(fft(Stp_rang(h,:)));
end
subplot(212);
mesh(1:rep_Number,1:N,Stp_fft);
title('脉冲压缩前FFT后信号幅度');
%自相关
t = linspace(0,T,N);
Stp_fd_single_huibo=exp(1j*2*pi*fd.*t).*Stp_fashe;
Ht=conj(fliplr(Stp_fd_single_huibo));
match_filter=fliplr(Stp_fashe);
match_filter=conj(match_filter);
Stp_convolution2=conv(match_filter,Stp_fd_single_huibo);
Stp_convolution2_abs=abs(Stp_convolution2);
St_convolution_log=10*log10(Stp_convolution2_abs);
figure(8);
subplot(111);
plot(St_convolution_log);
title('脉冲压缩后多普勒回波信号时域波形');
grid on;axis tight;
pks = sort( findpeaks(St_convolution_log),'descend');
pk=pks(1)-pks(2);
%脉冲压缩后
match_filter=fliplr(Stp_fashe);
match_filter=conj(match_filter);
huibo_an = A*Stp_fd_huibo;
huibo_nn = St_noise - A*Stp_fd_huibo;
maiya_zhin = conv(match_filter,huibo_nn);
maiya_non = conv(match_filter,huibo_an);
So_1 = 10*log10(max(abs(maiya_non))^2);
No_1 = 10*log10(sum(abs(maiya_zhin.^2))/(rep_Number*N-1));
snr1 = So_1 - No_1;
D = snr1 -SNR;
%FFT后
for r=1:rep_Number
for h=1:N
s_hb1zn(h,r)=maiya_zhin((r-1)*N+h);
end
end
for h=1:N
r_fftzn(h,:)=abs(fft(s_hb1zn(h,:)));
end
for r=1:rep_Number
for h=1:N
s_hb1nn(h,r)=maiya_non((r-1)*N+h);
end
end
for h=1:N
r_fftn(h,:)=abs(fft(s_hb1nn(h,:)));
end
m1=max(r_fftn);
m2=max(m1);
So_fft=10*log10(m2^2);
m3=r_fftzn.^2;
No_fft=10*log10(sum(m3(:))/(rep_Number*N-1));
snr2=So_fft - No_fft;
D_fft = snr2 - SNR;
评论0