php中文网 | cnphp.com

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
搜索资源  
php中文网 | cnphp.com 资源中心 源码 matlab 无源探测交汇定位Matlab仿真: _Intersection_localization.m

资源分类

无源探测交汇定位Matlab仿真: _Intersection_localization.m

 

无源探测交汇定位Matlab仿真:
【代码名称】:无源探测交汇定位Matlab仿真

【代码介绍】:无源探测交汇定位Matlab仿真

【代码截图】:
  1. clear;
  2. clc;
  3. close all;


  4. % a = 45;
  5. % b = 45;
  6. % r = (b-a).*rand(1,1) + a;
  7. % dis = 25e3;           %100km
  8. tar_loc = [45 25e3]';  
  9. targetloc = [ tar_loc(2)*sind( tar_loc(1) );tar_loc(2)*cosd( tar_loc(1) ) ]; % 目标x-y坐标位置

  10. T = 60*5;
  11. v = 100/3.6;
  12. thetaAir = tar_loc(1) + 45;      % 飞机航向,单位°  acosd(10/25)
  13. deltaT = 1;      % 每deltaT秒计算一个角度和距离
  14. % initial_coor = 1000*rand(1,2);
  15. initial_coor = [0 0];

  16. rangeAir = v*deltaT:v*deltaT:v*T;    % 飞行位置向量
  17. radarloc_x = rangeAir*sind(thetaAir);     % 无人机航向X轴坐标
  18. radarloc_y = rangeAir*cosd(thetaAir);     % 无人机航向Y轴坐标
  19. radarloc = [initial_coor(1)+radarloc_x;initial_coor(2)+radarloc_y];   % 无人机x-y坐标位置,单位km
  20. sigma = 1;


  21. figure(1);hold on;
  22. plot(0,0,'xr','LineWidth',2);
  23. plot(targetloc(1),targetloc(2),'pr','LineWidth',2);
  24. plot(radarloc(1,:),radarloc(2,:),'-.b','LineWidth',0.5);


  25. Ax = [];
  26. Ay = [];
  27. Ae = [];


  28. for i = 1:T
  29.     x1 = initial_coor(1);
  30.     y1 = initial_coor(2);
  31.     x2 = radarloc_x(i);
  32.     y2 = radarloc_y(i);

  33.     theta1 = atand((x2 -initial_coor(1))/(y2-initial_coor(2))) - tar_loc(1);
  34.     theta2 = thetaAir - atand( ( x2 - targetloc(1) )./(  y2- targetloc(2) ) );
  35.     theta2 = theta2 + sigma*randn(1,1);

  36.     theta2 = smooth(theta2,500,'rloess');



  37.     x = (x2.*tand(theta2) - x1.*tand(theta1) + y1 - y2)./(tand(theta2)-tand(theta1));
  38.     y = (y1.*tand(theta2) - y2.*tand(theta1) + tand(theta1).*tand(theta2).*(x2-x1))./(tand(theta2)-tand(theta1));



  39.     Ax = [Ax;x];
  40.     Ay = [Ay;y];
  41.     xx = [x;y]';

  42.     error = dist_E(xx,targetloc');
  43.     error
  44.     error = error./tar_loc(2)*100;

  45.     error

  46.     Ae = [Ae;error];



  47. end
  48. figure(2);
  49. plot(Ae);
  50. title('误差变化');xlabel('时刻');ylabel('误差变化值');
  51. axis([0,T,0,50]);
  52. % ylim([0,100]);%确定Y轴的范围是-1到3
  53. set(gca,'YTick',[0:5:50]); %改变y轴坐标间隔显示 这里间隔为2


  54. figure(3);
  55. subplot(2,1,1);
  56. plot(Ax);hold on;
  57. plot([0,300],[targetloc(1),targetloc(1)],'r' ,'linewidth',2);
  58. plot([0,300],[targetloc(1)-0.05*tar_loc(2),targetloc(1)-0.05*tar_loc(2)],'b' ,'linewidth',1);
  59. plot([0,300],[targetloc(1)+0.05*tar_loc(2),targetloc(1)+0.05*tar_loc(2)],'b' ,'linewidth',1);
  60. title('x坐标变化');xlabel('时刻');ylabel('x坐标值');
  61. axis([0,T,0,2e5]);
  62. subplot(2,1,2);
  63. plot(Ay);hold on;
  64. plot([0,300],[targetloc(2),targetloc(2)],'r' ,'linewidth',2);
  65. plot([0,300],[targetloc(2)-0.05*tar_loc(2),targetloc(2)-0.05*tar_loc(2)],'b' ,'linewidth',1);
  66. plot([0,300],[targetloc(2)+0.05*tar_loc(2),targetloc(2)+0.05*tar_loc(2)],'b' ,'linewidth',1);
  67. title('y坐标变化');xlabel('时刻');ylabel('y坐标值');
  68. axis([0,T,0,2e5]);



  69. function dist = dist_E(x,y)
  70. dist = [x;y];
  71. dist = pdist(dist); % 计算各行向量之间的欧式距离
  72. end

复制代码


【代码下载】:

QQ|php中文网 | cnphp.com ( 赣ICP备2021002321号-2 )51LA统计

GMT+8, 2024-4-28 19:47 , Processed in 0.176993 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

申明:本站所有资源皆搜集自网络,相关版权归版权持有人所有,如有侵权,请电邮(fiorkn@foxmail.com)告之,本站会尽快删除。

返回顶部