www.pudn.com > lfm_5M.rar > lfm_5M.m, change:2017-04-13,size:5305b


close all; 
clear all; 
clc; 
 
T=100e-6;                                %信号的脉宽 
B=5e6;                                  %信号的调频带宽 
K=B/T;                                  %调频斜率 
Fs=60e6;                                 %采样率  
Ts=1/Fs;                                 %采样间隔 
fc=20e6;                                %中频频率 
 
N=T/Ts;                                  %一个周期采样点数 
fd1 = 1000;                              %目标1多普勒 
fd2 = -800;                                %目标2多普勒 
T1 = 1e-6;                                %目标1延时时间 
T2 = 2e-6;                                %目标2延时时间 
NT = 512;                                  %积累周期数 
D = 6;                                    %抽取倍数 
SNR=-20;                                     %回波信噪比 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
t=(-N/2:N/2)*Ts; 
Stt_I=real(exp(sqrt(-1)*2*pi*((fc)*t+(K/2)*t.^2)));    %产生单周期线性调频信号 
Stt_Q=imag(exp(sqrt(-1)*2*pi*((fc)*t+(K/2)*t.^2))); 
% Stt=exp(sqrt(-1)*2*pi*((fc)*t+(K/2)*t.^2)); 
figure; 
subplot(211) 
plot(t*1e6,real(Stt_Q)); 
xlabel('Time in u sec');                  %横坐标时间的单位是微秒 
title('线性调频信号的时域波形'); 
grid on;axis tight; %将图形加上网格并把数轴的尺度限定在数据范围内 
n1=1:length(Stt_Q); 
f1=(n1/length(Stt_Q))*Fs; 
subplot(212) 
plot(f1/1e6,(abs(fft(Stt_Q)))); 
xlabel('Frequency in MHz');              %横坐标频率的单位是MHz 
title('线性调频信号的幅频特性'); 
grid on;axis tight; 
%---------前面产生的Stt为单周期中频线性调频信号--------% 
 
%------------------------下面将产生中频线性调频信号连续波--------------------% 
 
S = repmat(Stt_I,1,NT+2);           %周期扩展 
S_Q= repmat(Stt_Q,1,NT+2);           %周期扩展 
clear Stt_I; 
clear Stt_Q; 
%-------------------------------------------------------------------------% 
 
%-----------------------------对中频信号加多普勒-----------------------------% 
 
t1 = (1:length(S))*Ts; 
SS1 = real(hilbert(S).*exp(sqrt(-1)*2*pi*fd1*t1));    %目标1加多普勒 
SS2 = real(hilbert(S).*exp(sqrt(-1)*2*pi*fd2*t1));    %目标2加多普勒 
%n1=1:length(SS1); 
%f1=(n1/length(SS1))*Fs; 
%plot(f1/1e6,(abs(fft(SS1)))); 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%延时信息的相关设置%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%%将延时时间转化为程序当中的“点数信息”%%%%%%%%% 
P1 = T1 * Fs;   %延时大小,标出的数值是由Fs采样率得到 
SS11 = [zeros(1,P1) SS1(1:length(SS1)-P1)]; 
 
P2 = T2 * Fs; 
SS22 = [zeros(1,P2) SS2(1:length(SS2)-P2)]; 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%回波加噪声%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%Huibo = 0.5*SS11 + SS22;             %产生2目标回波信号 
Huibo = SS11 ;                        %产生2目标回波信号 
Huibo = awgn(Huibo,SNR,'measured'); 
 
%----------延时中频信号与中频信号混频-----------% 
SSS = real(S(T*Fs+1:T*Fs*(NT+1))).*Huibo(T*Fs+1:T*Fs*(NT+1)); 
SSS_Q = real(S_Q(T*Fs+1:T*Fs*(NT+1))).*Huibo(T*Fs+1:T*Fs*(NT+1)); 
%SSS = real(Huibo(T*Fs+1:T*Fs*(NT+1))).*S(T*Fs+1:T*Fs*(NT+1)); 
%SSS_Q = real(Huibo(T*Fs+1:T*Fs*(NT+1))).*S_Q(T*Fs+1:T*Fs*(NT+1)); 
% N1 = length(SSS); 
 
clear S SS1 SS2 SS11 SS22; 
 
%%%%%%%%%%%%%%%%%%%%%%对混频后的信号进行低通处理%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%由于在前面已经设定了延时时间T1为100us,则根据公式T1=(2*R)/c可以计算出目标距离%%% 
%%%%再根据公式f=B*(2*R)/(T*c)可以算出理论上对应的频差,其中c为光速:3e8%%%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%所以,频差f=B*T1/T %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
f_ideal1=(B*T1)/T %%%%%计算获得理论上的频差 
f_ideal2=(B*T2)/T %%%%%计算获得理论上的频差 
 
%----------产生下变频后要用的低通滤波器(使用的是kaiserord窗)---------------- 
fcuts = [50e4 75e4]; 
mags = [1 0];    %表示低通 
devs = [0.01 0.01];  
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,Fs); 
lp = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale');        %fir低通滤波器系数 
% %------------------------------------------------------------------------ 
 
%------------------------------低通滤波------------------------------------- 
% SSS_r =filter(lp,1,real(SSS));   % 
% SSS_i =filter(lp,1,imag(SSS));   % 
% SSS = SSS_r + sqrt(-1)*SSS_i; 
% clear SSS; 
SSS =filter(lp,1,SSS); 
SSS_Q=filter(lp,1,SSS_Q); 
clear lp; 
%figure; 
%plot(SSS(1:14000)); 
% title('差拍信号时域波形(低通滤波后)'); 
% xlabel('样点数'); 
% ylabel('信号幅度(V)'); 
%title('线性调频信号的幅频特性'); 
% axis tight; 
SSS=SSS+j*SSS_Q; 
 
%----------------计算延时混频后的频差f(通过频差可以计算出目标的距离)---------% 
 
f_1=linspace(0,1,length(SSS))*Fs; 
figure; 
plot(f_1,abs(fft(SSS))); 
xlabel('Frequency in Hz');              %横坐标频率的单位是Hz 
title('差频'); 
%axis([0,5e6,0,1.5e6]); 
% f_1=linspace(0,1,N)*Fs; 
% figure; 
% plot(f_1,(abs(fft(SSS_r(1:N))))); 
% xlabel('Frequency in Hz');              %横坐标频率的单位是Hz 
% title('差频'); 
%axis([0,2e6,0,5e5]); 
 
%%%%%%%%需要将速率为FS的数据进行抽取操作,抽取倍数为Fs/f_ideal;%%%%%%%%%%%%% 
% coqv=Fs/f_ideal/2;        %获得抽取倍数 
 
SSS = SSS(1:D:end);        %6倍抽取 
H1 = reshape(SSS,T*Fs/D,NT); %数据重排 
% clear SSS_r; 
 
 
H1 = fft(H1);               %横向fft 
H2 = fft(H1.');              %纵向fft 
H2 = abs(H2); 
clear H1; 
[m,n] = size(H2); 
H2 = H2(1:end,1:n/2); 
figure; 
% mesh(20*log(abs(H3))) 
mesh(20*log10(H2)); 
% figure; 
% mesh(20*log10(abs(H3))); 
xlabel('X:距离'); 
ylabel('Y:速度'); 
title('距离-多普勒三维图'); 
axis tight; 
[rows,cols] = find(H2 == max(max(H2)))