MATLAB雷达信号处理

 
  1. close all;clearvars;clc;

  2. dbstop if error;

  3. fid = fopen('tempiqa1.dat' , 'w+');

  4. %% 模拟目标运动轨迹以及天线的基本参数

  5. Pt = 10e-3; %发送信号功率w

  6. Gt = 10; %天线增益 db

  7. RCS =1.5; %取汽车的典型值,反射物的横截面积 平方米

  8. ADCsamplef1 = 2e6; %ADC采样率,主要是由于其中存在等待,为了保证时长的准确,此处chirp时长为8us ; 其中3us采样,5us等待

  9. Framet = 50e-3; %扫频间隔为50ms

  10. c = 3E8;

  11. lambda = 3E8/77E9;

  12. Aeff = lambda/2 * 0.04; %接受天线的有效面积m^2

  13. numRxAnnate = 4; %接收天线个数

  14. d = lambda/2;

  15. DistanceOfEachAnnate = [0 d 2*d 3*d]; %接收天线间距,以第一幅接收天线为0,以后每一段为两幅接收天线之间的间距;

  16.  
  17. % sction1 距离精度高,速度精度低段

  18. SampleRsec1 = 16;

  19. SampleVsec1 = 1024;

  20. Bandsec1 = 20E6;

  21. T1 = 1/ADCsamplef1*(SampleRsec1);

  22. U1 = Bandsec1/T1;

  23. DR1 = c/ 2 / Bandsec1;

  24. DV1 = lambda/ 2 / T1 / SampleVsec1;

  25. t1 = [0:SampleRsec1-1]/ADCsamplef1;

  26. F1 = zeros(SampleVsec1,SampleRsec1);

  27.  
  28. % sction2 距离精度高,速度精度低段

  29. ADCsamplef2 = 5.4e6; %ADC采样率,主要是由于其中存在等待,为了保证时长的准确,此处chirp时长为47us ; 其中42us采样,5us等待

  30. SampleRsec2 = 256;

  31. SampleVsec2 = 128;

  32. Bandsec2 = 800e6;

  33. T2 = 1/ADCsamplef2*(SampleRsec2);

  34. U2 = Bandsec2/T2;

  35. DR2 = c/ 2 / Bandsec2;

  36. DV2 = lambda/ 2 / T2 / SampleVsec2;

  37. t2 = [0:SampleRsec2-1]/ADCsamplef2;

  38. F2 = zeros(SampleVsec2,SampleRsec2);

  39.  
  40.  
  41. % 目标回波信号

  42. Frame = 300; %至少要大于目标的帧数

  43. TargetNumber = 3; %回波目标个数

  44. TargerFrameOrignalMatrix = [Frame Frame Frame]; %如果目标出现帧数帧数超出,则目标被删除

  45. TargerRangeOrignalMatrix = [25 5 13]; %m 距离

  46. TargerVolectyOrignalMatrix = [10 12 18]; %m/s 速度为正表示远离 , 速度为负表示靠近

  47. TargerAccelerationOrignalMatrix = [0 1 5]; %m/s ^2

  48. TargerRoadOrignalMatrix = [2 0 0]; %默认设定目标为直线运动,此处给出目标的车道位置,目标的角度信息由距离关系自动计算。其中0表示中间车道,左边为负右边为正

  49. Mode = 0;

  50.  
  51. %% 信号模拟

  52. %目标信号建模

  53. Fk = [1 Framet;0 1];

  54. Bk = [(Framet^2)/2 Framet]';

  55. % 峰值点结构体定义

  56. peakout.point_r = 0;peakout.point_v = 0;peakout.I1 = 0;peakout.Q1 = 0;

  57. peakout.I2 = 0;peakout.Q2 = 0;peakout.I3 = 0;peakout.Q3 = 0;peakout.I4 = 0;peakout.Q4 = 0;

  58. peaknum = 3072;

  59.  
  60. for i = 1 : TargetNumber %目标个数循环

  61.  
  62. Targetdeta = zeros(2 ,Frame );

  63. Targetdeta(:,1) = [TargerRangeOrignalMatrix(i) TargerVolectyOrignalMatrix(i)]';

  64.  
  65. for j = 2 : TargerFrameOrignalMatrix(i) %目标帧数循环

  66.  
  67. Targetdeta(1:2,j) = Fk*Targetdeta(1:2,j-1) + Bk.*TargerAccelerationOrignalMatrix(i);

  68. Targetdeta(3,j) = asind(3.6*TargerRoadOrignalMatrix(i) / Targetdeta(1 , j));

  69.  
  70. if (Targetdeta(1 , j) < 0)

  71. Targetdeta(1 , j) = 0;

  72. Targetdeta(2 , j) = 0;

  73. end

  74. end

  75.  
  76. Target(i).target = Targetdeta();

  77.  
  78.  
  79. Target(i).Pr = Pt*Gt./(4*pi.*Target(i).target(1,:).^2) .* RCS .* (1/4/pi./Target(i).target(1,:).^2.*Aeff);

  80. Target(i).sn = 1.3806505e-24 * 800e6 * (32+(9/5)*25);

  81.  
  82. end

  83.  
  84. figure;

  85. for i = 1 : TargetNumber

  86. plot(Target(i).target(1,:).*sind(Target(i).target(3,:)) , Target(i).target(1,:) , '*');

  87. hold on;

  88. end

  89.  
  90. % 模拟回波时域信号

  91. h1 = figure;

  92. h2 = figure;

  93. h3 = figure;

  94.  
  95. for cnt = 1 : Frame

  96.  
  97. set(0,'CurrentFigure' , h3);

  98. for i = 1 : TargetNumber

  99.  
  100. plot(cnt , Target(i).target(1,cnt) , 'o');

  101. hold on;

  102. xlabel('帧数');

  103. ylabel('距离');

  104. end

  105.  
  106. if(mod(cnt,2) == 0)

  107.  
  108. Mode = 1; %表示srsect1段 16*1024 20Mhz

  109. % 初始化天线存储内存

  110. for annatacnt = 1 : numRxAnnate

  111. srsec1(annatacnt).RX = zeros( SampleVsec1 , SampleRsec1);

  112. end

  113.  
  114. for k = 1 :TargetNumber

  115.  
  116. for anrxcnt = 1 : numRxAnnate

  117.  
  118. dphi(anrxcnt) = 2*pi*DistanceOfEachAnnate(anrxcnt)*sind(Target(k).target(3,cnt)) / lambda;

  119. end

  120.  
  121. %sec1 段回波数据模拟

  122. for i=1:SampleVsec1

  123. for j=1:SampleRsec1

  124. R = Target(k).target(1,cnt) +Target(k).target(2,cnt)*(i-1)*T1 + Target(k).target(2,cnt)*t1(j);

  125. f = 2*R/lambda + 2*U1*R*t1(j)/c;

  126. w = 2*pi*f;

  127. F1(i,j) = w + (rand(1)-0.5)/0.1/180*pi;

  128. end

  129. end

  130.  
  131. for i=1:SampleVsec1

  132. for j=1:SampleRsec1

  133. w = F1(i,j);

  134.  
  135. for anncnt = 1 : numRxAnnate

  136.  
  137. 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)

  138. end

  139.  
  140. end

  141. end

  142. end

  143. srsecrx1 = srsec1(1).RX';

  144. srsecrx2 = srsec1(2).RX';

  145. srsecrx3 = srsec1(3).RX';

  146. srsecrx4 = srsec1(4).RX';

  147.  
  148. black_manR = blackman(SampleRsec1);

  149. black_manV = blackman(SampleVsec1)';

  150. SR1 = srsecrx1.*repmat(black_manR,1,SampleVsec1);

  151. SR1 = SR1.*repmat(black_manV,SampleRsec1,1);

  152. fft_data1_1d = fft(SR1,SampleRsec1);

  153. fft_data1_1d = fft_data1_1d';

  154. fft_data1_2d = fft(fft_data1_1d,SampleVsec1);

  155. abs_data1 = abs(fft_data1_2d);

  156.  
  157. %

  158. SR2 = srsecrx2.*repmat(black_manR,1,SampleVsec1);

  159. SR2 = SR2.*repmat(black_manV,SampleRsec1,1);

  160. fft_data2_1d = fft(SR2,SampleRsec2);

  161. fft_data2_1d = fft_data2_1d';

  162. fft_data2_2d = fft(fft_data2_1d,SampleVsec1);

  163. abs_data2 = abs(fft_data2_2d);

  164.  
  165. %

  166. SR3 = srsecrx3.*repmat(black_manR,1,SampleVsec1);

  167. SR3 = SR3.*repmat(black_manV,SampleRsec1,1);

  168. fft_data3_1d = fft(SR3,SampleRsec1);

  169. fft_data3_1d = fft_data3_1d';

  170. fft_data3_2d = fft(fft_data3_1d,SampleVsec1);

  171. abs_data3 = abs(fft_data3_2d);

  172. %

  173.  
  174. SR4 = srsecrx4.*repmat(black_manR,1,SampleVsec1);

  175. SR4 = SR4.*repmat(black_manV,SampleRsec1,1);

  176. fft_data4_1d = fft(SR4,SampleRsec1);

  177. fft_data4_1d = fft_data4_1d';

  178. fft_data4_2d = fft(fft_data4_1d,SampleVsec1);

  179. abs_data4 = abs(fft_data4_2d);

  180.  
  181. set(0,'CurrentFigure' , h1);

  182. mesh(abs_data1);

  183. title( strcat('一维20Mhz 16点 ; dr = ' , num2str(DR1) ,'m ; 二维1024点; dv = ' , num2str(DV1) , 'm/s'));

  184. xlabel('距离维');

  185. ylabel('速度维');

  186. else

  187.  
  188. Mode = 2; %表示srsect1段 256*128 800Mhz

  189. % 初始化天线存储内存

  190. for annatacnt = 1 : numRxAnnate

  191.  
  192. srsec2(annatacnt).RX = zeros( SampleVsec2 , SampleRsec2);

  193. end

  194.  
  195. %sec2 段回波数据模拟

  196. for k = 1 :TargetNumber

  197.  
  198. for anrxcnt = 1 : numRxAnnate

  199.  
  200. dphi(anrxcnt) = 2*pi*DistanceOfEachAnnate(anrxcnt)*sind(Target(k).target(3,cnt)) / lambda;

  201. end

  202.  
  203. %sec2 段回波数据模拟

  204. for i=1:SampleVsec2

  205. for j=1:SampleRsec2

  206. R = Target(k).target(1,cnt) +Target(k).target(2,cnt)*(i-1)*T2 + Target(k).target(2,cnt)*t2(j);

  207. f = 2*R/lambda + 2*U2*R*t2(j)/c;

  208. w = 2*pi*f;

  209. F2(i,j) = w + (rand(1)-0.5)/0.1/180*pi;

  210. end

  211. end

  212.  
  213. for i=1:SampleVsec2

  214. for j=1:SampleRsec2

  215. w = F2(i,j);

  216.  
  217. for anncnt = 1 : numRxAnnate

  218.  
  219. 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);

  220. end

  221. end

  222. end

  223. end

  224.  
  225. srsecrx1 = srsec2(1).RX';

  226. srsecrx2 = srsec2(2).RX';

  227. srsecrx3 = srsec2(3).RX';

  228. srsecrx4 = srsec2(4).RX';

  229.  
  230. black_manR = blackman(SampleRsec2);

  231. black_manV = blackman(SampleVsec2)';

  232. SR1 = srsecrx1.*repmat(black_manR,1,SampleVsec2);

  233. SR1 = SR1.*repmat(black_manV,SampleRsec2,1);

  234. fft_data1_1d = fft(SR1,SampleRsec2);

  235. fft_data1_1d = fft_data1_1d';

  236. fft_data1_2d = fft(fft_data1_1d,SampleVsec2);

  237. abs_data1 = abs(fft_data1_2d);

  238.  
  239. %

  240. SR2 = srsecrx2.*repmat(black_manR,1,SampleVsec2);

  241. SR2 = SR2.*repmat(black_manV,SampleRsec2,1);

  242. fft_data2_1d = fft(SR2,SampleRsec2);

  243. fft_data2_1d = fft_data2_1d';

  244. fft_data2_2d = fft(fft_data2_1d,SampleVsec2);

  245. abs_data2 = abs(fft_data2_2d);

  246.  
  247. %

  248. SR3 = srsecrx3.*repmat(black_manR,1,SampleVsec2);

  249. SR3 = SR3.*repmat(black_manV,SampleRsec2,1);

  250. fft_data3_1d = fft(SR3,SampleRsec2);

  251. fft_data3_1d = fft_data3_1d';

  252. fft_data3_2d = fft(fft_data3_1d,SampleVsec2);

  253. abs_data3 = abs(fft_data3_2d);

  254. %

  255.  
  256. SR4 = srsecrx4.*repmat(black_manR,1,SampleVsec2);

  257. SR4 = SR4.*repmat(black_manV,SampleRsec2,1);

  258. fft_data4_1d = fft(SR4,SampleRsec2);

  259. fft_data4_1d = fft_data4_1d';

  260. fft_data4_2d = fft(fft_data4_1d,SampleVsec2);

  261. abs_data4 = abs(fft_data4_2d);

  262.  
  263. set(0,'CurrentFigure' , h2);

  264. mesh(abs_data1);

  265. title( strcat('一维800Mhz 256点 ; dr = ' , num2str(DR2) ,'m ; 二维128点; dv = ' , num2str(DV2) , 'm/s'));

  266. xlabel('距离维');

  267. ylabel('速度维');

  268. end

  269.  
  270. %% 找峰值点,并把峰值点传出来

  271. avemeans = mean(abs_data1)*1.5;

  272. avemeans = repmat(avemeans , size(abs_data1 , 1) , 1);

  273. peak_matrix = imregionalmax(abs_data1);

  274. peak_matrix = peak_matrix .* abs_data1;

  275. peak_matrix(peak_matrix < avemeans) = 0;

  276. peak_matrix = peak_matrix * 1e6;

  277. g_menxian = avemeans(1,:)*1e6;

  278. [point_r point_v]= find(peak_matrix > 0);

  279.  
  280. len = length(point_r);

  281. if len > 3072

  282. len = 3072;

  283. end

  284.  
  285. for peakcnt = 1 : 3072

  286. peakout(peakcnt).point_r = 0; peakout(peakcnt).point_v=0;

  287. peakout(peakcnt).I1 = 0;peakout(peakcnt).Q1 = 0;

  288. peakout(peakcnt).I2 = 0; peakout(peakcnt).Q2 = 0;

  289. peakout(peakcnt).I3 = 0; peakout(peakcnt).Q3 = 0;

  290. peakout(peakcnt).I4 = 0; peakout(peakcnt).Q4 = 0;

  291. end

  292. %peak_matrix为峰值点位置 ; g_menxian为门限值,之后组帧数据传输出去

  293. for peakcnt = 1 : length(point_r)

  294.  
  295. peakout(peakcnt).point_r = point_r(peakcnt);

  296. peakout(peakcnt).point_v = point_v(peakcnt);

  297. peakout(peakcnt).I1 = real(fft_data1_2d( point_r(peakcnt) , point_v(peakcnt))) * 1e6;

  298. peakout(peakcnt).Q1 = imag(fft_data1_2d( point_r(peakcnt) , point_v(peakcnt))) * 1e6;

  299. peakout(peakcnt).I2 = real(fft_data2_2d( point_r(peakcnt) , point_v(peakcnt))) * 1e6;

  300. peakout(peakcnt).Q2 = imag(fft_data2_2d( point_r(peakcnt) , point_v(peakcnt))) * 1e6;

  301. peakout(peakcnt).I3 = real(fft_data3_2d( point_r(peakcnt) , point_v(peakcnt))) * 1e6;

  302. peakout(peakcnt).Q3 = imag(fft_data3_2d( point_r(peakcnt) , point_v(peakcnt))) * 1e6;

  303. peakout(peakcnt).I4 = real(fft_data4_2d( point_r(peakcnt) , point_v(peakcnt))) * 1e6;

  304. peakout(peakcnt).Q4 = imag(fft_data4_2d( point_r(peakcnt) , point_v(peakcnt))) * 1e6;

  305. end

  306.  
  307. for peakcnt = 1 : 3072

  308.  
  309. fwrite(fid, peakout(peakcnt).point_r , 'uint16');

  310. fwrite(fid, peakout(peakcnt).point_v , 'uint16');

  311. fwrite(fid, int16(peakout(peakcnt).I1) , 'int16');

  312. fwrite(fid, int16(peakout(peakcnt).Q1) , 'int16');

  313. fwrite(fid, int16(peakout(peakcnt).I2) , 'int16');

  314. fwrite(fid, int16(peakout(peakcnt).Q2) , 'int16');

  315. fwrite(fid, int16(peakout(peakcnt).I3) , 'int16');

  316. fwrite(fid, int16(peakout(peakcnt).Q3) , 'int16');

  317. fwrite(fid, int16(peakout(peakcnt).I4) , 'int16');

  318. fwrite(fid, int16(peakout(peakcnt).Q4) , 'int16');

  319.  
  320. end

  321.  
  322. pause(0.01);

  323. end

  324.  
  325. fclose(fid);

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页