close all;clearvars;clc; dbstop if error; fid = fopen('tempiqa1.dat' , 'w+');
%% 模拟目标运动轨迹以及天线的基本参数 Pt = 10e-3; %发送信号功率w Gt = 10; %天线增益 db RCS =1.5;
%取汽车的典型值,反射物的横截面积 平方米 ADCsamplef1 = 2e6;
%ADC采样率,主要是由于其中存在等待,为了保证时长的准确,此处chirp时长为8us ; 其中3us采样,5us等待 Framet = 50e-3;
%扫频间隔为50ms c = 3E8; lambda = 3E8/77E9; Aeff = lambda/2 * 0.04; %接受天线的有效面积m^2
numRxAnnate = 4; %接收天线个数 d = lambda/2; DistanceOfEachAnnate = [0 d 2*d 3*d];
%接收天线间距,以第一幅接收天线为0,以后每一段为两幅接收天线之间的间距; % sction1 距离精度高,速度精度低段 SampleRsec1 = 16;
SampleVsec1 = 1024; Bandsec1 = 20E6; T1 = 1/ADCsamplef1*(SampleRsec1); U1 =
Bandsec1/T1; DR1 = c/ 2 / Bandsec1; DV1 = lambda/ 2 / T1 / SampleVsec1; t1 =
[0:SampleRsec1-1]/ADCsamplef1; F1 = zeros(SampleVsec1,SampleRsec1); % sction2
距离精度高,速度精度低段 ADCsamplef2 = 5.4e6; %ADC采样率,主要是由于其中存在等待,为了保证时长的准确,此处chirp时长为47us
; 其中42us采样,5us等待 SampleRsec2 = 256; SampleVsec2 = 128; Bandsec2 = 800e6; T2 =
1/ADCsamplef2*(SampleRsec2); U2 = Bandsec2/T2; DR2 = c/ 2 / Bandsec2; DV2 =
lambda/ 2 / T2 / SampleVsec2; t2 = [0:SampleRsec2-1]/ADCsamplef2; F2 =
zeros(SampleVsec2,SampleRsec2); % 目标回波信号 Frame = 300; %至少要大于目标的帧数 TargetNumber
= 3; %回波目标个数 TargerFrameOrignalMatrix = [Frame Frame Frame];
%如果目标出现帧数帧数超出,则目标被删除 TargerRangeOrignalMatrix = [25 5 13]; %m 距离
TargerVolectyOrignalMatrix = [10 12 18]; %m/s 速度为正表示远离 , 速度为负表示靠近
TargerAccelerationOrignalMatrix = [0 1 5]; %m/s ^2 TargerRoadOrignalMatrix = [2
0 0]; %默认设定目标为直线运动,此处给出目标的车道位置,目标的角度信息由距离关系自动计算。其中0表示中间车道,左边为负右边为正 Mode = 0; %%
信号模拟 %目标信号建模 Fk = [1 Framet;0 1]; Bk = [(Framet^2)/2 Framet]'; % 峰值点结构体定义
peakout.point_r = 0;peakout.point_v = 0;peakout.I1 = 0;peakout.Q1 = 0;
peakout.I2 = 0;peakout.Q2 = 0;peakout.I3 = 0;peakout.Q3 = 0;peakout.I4 =
0;peakout.Q4 = 0; peaknum = 3072; for i = 1 : TargetNumber %目标个数循环 Targetdeta =
zeros(2 ,Frame ); Targetdeta(:,1) = [TargerRangeOrignalMatrix(i)
TargerVolectyOrignalMatrix(i)]'; for j = 2 : TargerFrameOrignalMatrix(i)
%目标帧数循环 Targetdeta(1:2,j) = Fk*Targetdeta(1:2,j-1) +
Bk.*TargerAccelerationOrignalMatrix(i); Targetdeta(3,j) =
asind(3.6*TargerRoadOrignalMatrix(i) / Targetdeta(1 , j)); if (Targetdeta(1 ,
j) < 0) Targetdeta(1 , j) = 0; Targetdeta(2 , j) = 0; end end Target(i).target
= Targetdeta(); Target(i).Pr = Pt*Gt./(4*pi.*Target(i).target(1,:).^2) .* RCS
.* (1/4/pi./Target(i).target(1,:).^2.*Aeff); Target(i).sn = 1.3806505e-24 *
800e6 * (32+(9/5)*25); end figure; for i = 1 : TargetNumber
plot(Target(i).target(1,:).*sind(Target(i).target(3,:)) , Target(i).target(1,:)
, '*'); hold on; end % 模拟回波时域信号 h1 = figure; h2 = figure; h3 = figure; for cnt
= 1 : Frame set(0,'CurrentFigure' , h3); for i = 1 : TargetNumber plot(cnt ,
Target(i).target(1,cnt) , 'o'); hold on; xlabel('帧数'); ylabel('距离'); end
if(mod(cnt,2) == 0) Mode = 1; %表示srsect1段 16*1024 20Mhz % 初始化天线存储内存 for
annatacnt = 1 : numRxAnnate srsec1(annatacnt).RX = zeros( SampleVsec1 ,
SampleRsec1); end for k = 1 :TargetNumber for anrxcnt = 1 : numRxAnnate
dphi(anrxcnt) =
2*pi*DistanceOfEachAnnate(anrxcnt)*sind(Target(k).target(3,cnt)) / lambda; end
%sec1 段回波数据模拟 for i=1:SampleVsec1 for j=1:SampleRsec1 R =
Target(k).target(1,cnt) +Target(k).target(2,cnt)*(i-1)*T1 +
Target(k).target(2,cnt)*t1(j); f = 2*R/lambda + 2*U1*R*t1(j)/c; w = 2*pi*f;
F1(i,j) = w + (rand(1)-0.5)/0.1/180*pi; end end for i=1:SampleVsec1 for
j=1:SampleRsec1 w = F1(i,j); for anncnt = 1 : numRxAnnate
srsec1(anncnt).RX(i,j) = srsec1(anncnt).RX(i,j) +sqrt( Target(k).Pr(cnt))*
exp(sqrt(-1)*(w + dphi(anncnt))) + (rand(1) - 0.5)* sqrt( Target(k).sn);% *
%dphi(anncnt) end end end end srsecrx1 = srsec1(1).RX'; srsecrx2 =
srsec1(2).RX'; srsecrx3 = srsec1(3).RX'; srsecrx4 = srsec1(4).RX'; black_manR =
blackman(SampleRsec1); black_manV = blackman(SampleVsec1)'; SR1 =
srsecrx1.*repmat(black_manR,1,SampleVsec1); SR1 =
SR1.*repmat(black_manV,SampleRsec1,1); fft_data1_1d = fft(SR1,SampleRsec1);
fft_data1_1d = fft_data1_1d'; fft_data1_2d = fft(fft_data1_1d,SampleVsec1);
abs_data1 = abs(fft_data1_2d); % SR2 =
srsecrx2.*repmat(black_manR,1,SampleVsec1); SR2 =
SR2.*repmat(black_manV,SampleRsec1,1); fft_data2_1d = fft(SR2,SampleRsec2);
fft_data2_1d = fft_data2_1d'; fft_data2_2d = fft(fft_data2_1d,SampleVsec1);
abs_data2 = abs(fft_data2_2d); % SR3 =
srsecrx3.*repmat(black_manR,1,SampleVsec1); SR3 =
SR3.*repmat(black_manV,SampleRsec1,1); fft_data3_1d = fft(SR3,SampleRsec1);
fft_data3_1d = fft_data3_1d'; fft_data3_2d = fft(fft_data3_1d,SampleVsec1);
abs_data3 = abs(fft_data3_2d); % SR4 =
srsecrx4.*repmat(black_manR,1,SampleVsec1); SR4 =
SR4.*repmat(black_manV,SampleRsec1,1); fft_data4_1d = fft(SR4,SampleRsec1);
fft_data4_1d = fft_data4_1d'; fft_data4_2d = fft(fft_data4_1d,SampleVsec1);
abs_data4 = abs(fft_data4_2d); set(0,'CurrentFigure' , h1); mesh(abs_data1);
title( strcat('一维20Mhz 16点 ; dr = ' , num2str(DR1) ,'m ; 二维1024点; dv = ' ,
num2str(DV1) , 'm/s')); xlabel('距离维'); ylabel('速度维'); else Mode = 2;
%表示srsect1段 256*128 800Mhz % 初始化天线存储内存 for annatacnt = 1 : numRxAnnate
srsec2(annatacnt).RX = zeros( SampleVsec2 , SampleRsec2); end %sec2 段回波数据模拟 for
k = 1 :TargetNumber for anrxcnt = 1 : numRxAnnate dphi(anrxcnt) =
2*pi*DistanceOfEachAnnate(anrxcnt)*sind(Target(k).target(3,cnt)) / lambda; end
%sec2 段回波数据模拟 for i=1:SampleVsec2 for j=1:SampleRsec2 R =
Target(k).target(1,cnt) +Target(k).target(2,cnt)*(i-1)*T2 +
Target(k).target(2,cnt)*t2(j); f = 2*R/lambda + 2*U2*R*t2(j)/c; w = 2*pi*f;
F2(i,j) = w + (rand(1)-0.5)/0.1/180*pi; end end for i=1:SampleVsec2 for
j=1:SampleRsec2 w = F2(i,j); for anncnt = 1 : numRxAnnate
srsec2(anncnt).RX(i,j) = srsec2(anncnt).RX(i,j) + sqrt( Target(k).Pr(cnt)) *
exp(sqrt(-1)*(w + dphi(anncnt)))+ (rand(1) - 0.5)* sqrt( Target(k).sn); end end
end end srsecrx1 = srsec2(1).RX'; srsecrx2 = srsec2(2).RX'; srsecrx3 =
srsec2(3).RX'; srsecrx4 = srsec2(4).RX'; black_manR = blackman(SampleRsec2);
black_manV = blackman(SampleVsec2)'; SR1 =
srsecrx1.*repmat(black_manR,1,SampleVsec2); SR1 =
SR1.*repmat(black_manV,SampleRsec2,1); fft_data1_1d = fft(SR1,SampleRsec2);
fft_data1_1d = fft_data1_1d'; fft_data1_2d = fft(fft_data1_1d,SampleVsec2);
abs_data1 = abs(fft_data1_2d); % SR2 =
srsecrx2.*repmat(black_manR,1,SampleVsec2); SR2 =
SR2.*repmat(black_manV,SampleRsec2,1); fft_data2_1d = fft(SR2,SampleRsec2);
fft_data2_1d = fft_data2_1d'; fft_data2_2d = fft(fft_data2_1d,SampleVsec2);
abs_data2 = abs(fft_data2_2d); % SR3 =
srsecrx3.*repmat(black_manR,1,SampleVsec2); SR3 =
SR3.*repmat(black_manV,SampleRsec2,1); fft_data3_1d = fft(SR3,SampleRsec2);
fft_data3_1d = fft_data3_1d'; fft_data3_2d = fft(fft_data3_1d,SampleVsec2);
abs_data3 = abs(fft_data3_2d); % SR4 =
srsecrx4.*repmat(black_manR,1,SampleVsec2); SR4 =
SR4.*repmat(black_manV,SampleRsec2,1); fft_data4_1d = fft(SR4,SampleRsec2);
fft_data4_1d = fft_data4_1d'; fft_data4_2d = fft(fft_data4_1d,SampleVsec2);
abs_data4 = abs(fft_data4_2d); set(0,'CurrentFigure' , h2); mesh(abs_data1);
title( strcat('一维800Mhz 256点 ; dr = ' , num2str(DR2) ,'m ; 二维128点; dv = ' ,
num2str(DV2) , 'm/s')); xlabel('距离维'); ylabel('速度维'); end %% 找峰值点,并把峰值点传出来
avemeans = mean(abs_data1)*1.5; avemeans = repmat(avemeans , size(abs_data1 ,
1) , 1); peak_matrix = imregionalmax(abs_data1); peak_matrix = peak_matrix .*
abs_data1; peak_matrix(peak_matrix < avemeans) = 0; peak_matrix = peak_matrix *
1e6; g_menxian = avemeans(1,:)*1e6; [point_r point_v]= find(peak_matrix > 0);
len = length(point_r); if len > 3072 len = 3072; end for peakcnt = 1 : 3072
peakout(peakcnt).point_r = 0; peakout(peakcnt).point_v=0; peakout(peakcnt).I1 =
0;peakout(peakcnt).Q1 = 0; peakout(peakcnt).I2 = 0; peakout(peakcnt).Q2 = 0;
peakout(peakcnt).I3 = 0; peakout(peakcnt).Q3 = 0; peakout(peakcnt).I4 = 0;
peakout(peakcnt).Q4 = 0; end %peak_matrix为峰值点位置 ; g_menxian为门限值,之后组帧数据传输出去 for
peakcnt = 1 : length(point_r) peakout(peakcnt).point_r = point_r(peakcnt);
peakout(peakcnt).point_v = point_v(peakcnt); peakout(peakcnt).I1 =
real(fft_data1_2d( point_r(peakcnt) , point_v(peakcnt))) * 1e6;
peakout(peakcnt).Q1 = imag(fft_data1_2d( point_r(peakcnt) , point_v(peakcnt)))
* 1e6; peakout(peakcnt).I2 = real(fft_data2_2d( point_r(peakcnt) ,
point_v(peakcnt))) * 1e6; peakout(peakcnt).Q2 = imag(fft_data2_2d(
point_r(peakcnt) , point_v(peakcnt))) * 1e6; peakout(peakcnt).I3 =
real(fft_data3_2d( point_r(peakcnt) , point_v(peakcnt))) * 1e6;
peakout(peakcnt).Q3 = imag(fft_data3_2d( point_r(peakcnt) , point_v(peakcnt)))
* 1e6; peakout(peakcnt).I4 = real(fft_data4_2d( point_r(peakcnt) ,
point_v(peakcnt))) * 1e6; peakout(peakcnt).Q4 = imag(fft_data4_2d(
point_r(peakcnt) , point_v(peakcnt))) * 1e6; end for peakcnt = 1 : 3072
fwrite(fid, peakout(peakcnt).point_r , 'uint16'); fwrite(fid,
peakout(peakcnt).point_v , 'uint16'); fwrite(fid, int16(peakout(peakcnt).I1) ,
'int16'); fwrite(fid, int16(peakout(peakcnt).Q1) , 'int16'); fwrite(fid,
int16(peakout(peakcnt).I2) , 'int16'); fwrite(fid, int16(peakout(peakcnt).Q2) ,
'int16'); fwrite(fid, int16(peakout(peakcnt).I3) , 'int16'); fwrite(fid,
int16(peakout(peakcnt).Q3) , 'int16'); fwrite(fid, int16(peakout(peakcnt).I4) ,
'int16'); fwrite(fid, int16(peakout(peakcnt).Q4) , 'int16'); end pause(0.01);
end fclose(fid);