威望0
积分7976
贡献0
在线时间763 小时
UID1
注册时间2021-4-14
最后登录2024-11-24
管理员
- UID
- 1
- 威望
- 0
- 积分
- 7976
- 贡献
- 0
- 注册时间
- 2021-4-14
- 最后登录
- 2024-11-24
- 在线时间
- 763 小时
|
【代码名称】:无源探测交汇定位Matlab仿真
【代码介绍】:无源探测交汇定位Matlab仿真
【代码截图】:- clear;
- clc;
- close all;
- % a = 45;
- % b = 45;
- % r = (b-a).*rand(1,1) + a;
- % dis = 25e3; %100km
- tar_loc = [45 25e3]';
- targetloc = [ tar_loc(2)*sind( tar_loc(1) );tar_loc(2)*cosd( tar_loc(1) ) ]; % 目标x-y坐标位置
- T = 60*5;
- v = 100/3.6;
- thetaAir = tar_loc(1) + 45; % 飞机航向,单位° acosd(10/25)
- deltaT = 1; % 每deltaT秒计算一个角度和距离
- % initial_coor = 1000*rand(1,2);
- initial_coor = [0 0];
- rangeAir = v*deltaT:v*deltaT:v*T; % 飞行位置向量
- radarloc_x = rangeAir*sind(thetaAir); % 无人机航向X轴坐标
- radarloc_y = rangeAir*cosd(thetaAir); % 无人机航向Y轴坐标
- radarloc = [initial_coor(1)+radarloc_x;initial_coor(2)+radarloc_y]; % 无人机x-y坐标位置,单位km
- sigma = 1;
- figure(1);hold on;
- plot(0,0,'xr','LineWidth',2);
- plot(targetloc(1),targetloc(2),'pr','LineWidth',2);
- plot(radarloc(1,:),radarloc(2,:),'-.b','LineWidth',0.5);
- Ax = [];
- Ay = [];
- Ae = [];
- for i = 1:T
- x1 = initial_coor(1);
- y1 = initial_coor(2);
- x2 = radarloc_x(i);
- y2 = radarloc_y(i);
- theta1 = atand((x2 -initial_coor(1))/(y2-initial_coor(2))) - tar_loc(1);
- theta2 = thetaAir - atand( ( x2 - targetloc(1) )./( y2- targetloc(2) ) );
- theta2 = theta2 + sigma*randn(1,1);
- theta2 = smooth(theta2,500,'rloess');
- x = (x2.*tand(theta2) - x1.*tand(theta1) + y1 - y2)./(tand(theta2)-tand(theta1));
- y = (y1.*tand(theta2) - y2.*tand(theta1) + tand(theta1).*tand(theta2).*(x2-x1))./(tand(theta2)-tand(theta1));
- Ax = [Ax;x];
- Ay = [Ay;y];
- xx = [x;y]';
- error = dist_E(xx,targetloc');
- error
- error = error./tar_loc(2)*100;
- error
- Ae = [Ae;error];
- end
- figure(2);
- plot(Ae);
- title('误差变化');xlabel('时刻');ylabel('误差变化值');
- axis([0,T,0,50]);
- % ylim([0,100]);%确定Y轴的范围是-1到3
- set(gca,'YTick',[0:5:50]); %改变y轴坐标间隔显示 这里间隔为2
- figure(3);
- subplot(2,1,1);
- plot(Ax);hold on;
- plot([0,300],[targetloc(1),targetloc(1)],'r' ,'linewidth',2);
- plot([0,300],[targetloc(1)-0.05*tar_loc(2),targetloc(1)-0.05*tar_loc(2)],'b' ,'linewidth',1);
- plot([0,300],[targetloc(1)+0.05*tar_loc(2),targetloc(1)+0.05*tar_loc(2)],'b' ,'linewidth',1);
- title('x坐标变化');xlabel('时刻');ylabel('x坐标值');
- axis([0,T,0,2e5]);
- subplot(2,1,2);
- plot(Ay);hold on;
- plot([0,300],[targetloc(2),targetloc(2)],'r' ,'linewidth',2);
- plot([0,300],[targetloc(2)-0.05*tar_loc(2),targetloc(2)-0.05*tar_loc(2)],'b' ,'linewidth',1);
- plot([0,300],[targetloc(2)+0.05*tar_loc(2),targetloc(2)+0.05*tar_loc(2)],'b' ,'linewidth',1);
- title('y坐标变化');xlabel('时刻');ylabel('y坐标值');
- axis([0,T,0,2e5]);
- function dist = dist_E(x,y)
- dist = [x;y];
- dist = pdist(dist); % 计算各行向量之间的欧式距离
- end
复制代码
【代码下载】:
_Intersection_localization.m
(2.8 KB, 下载次数: 232)
|
上一篇:matlab反演海洋环境因子下一篇:组合导航matlab仿真
|