clear;
q1=0.25;%目标运动扰动参数
q2=0.25;%目标运动扰动参数
T=0.5;
fai=[1,T,0,0;0,1,0,0;0,0,1,T;0,0,0,1]; %状态转移矩阵,Φ(k)
Q(:,:,1)=[T^3/3,T^2/2,0,0;T^2/2,T,0,0;0,0,T^3/3,T^2/2;0,0,T^2/2,T]*q1; %过程噪声方差,Q1(k)
Q(:,:,2)=[T^3/3,T^2/2,0,0;T^2/2,T,0,0;0,0,T^3/3,T^2/2;0,0,T^2/2,T]*q2; %过程噪声方差,Q2(k)
x0(:,1)=[100;9.62;200;5.56]; %目标1初始状态
x0(:,2)=[150;9.62;300;5.56]; %目标2初始状态
p0(:,:,1)=0*[32.4,0,0,0;0,0,0,0;0,0,36.2,0;0,0,0,0]; %目标1初始误差协方差
p0(:,:,2)=0*[32.4,0,0,0;0,0,0,0;0,0,36.2,0;0,0,0,0]; %目标2初始误差协方差
NT=2;%设置目标个数
step=100;%设置仿真步数
H=zeros(2,4,step,NT);%扩展Klamn滤波中的等价测量矩阵
I=eye(4);
D=1000;%两个基阵相距的距离,单位m
R(:,:,1)=[2,0;0,0.5*pi/180];%主对角元分别为基阵A的测距误差(单位:米)和测向误差(单位:弧度)
R(:,:,2)=[1.5,0;0,0.3*pi/180];%主对角元分别为基阵B的测距误差(单位:米)和测向误差(单位:弧度)
gama=9;%跟踪波门参数γ
P_gate=0.9997;%门概率
% Produce basic state and measurement
for k=1:step
for i=1:NT
w(:,k,i)=sqrtm(Q(:,:,i))*randn(4,1);%产生过程噪声
a=[0;0];
for t=1:1000
a=a+R(:,:,i)*randn(2,1);
t=t+1;
end
v(:,k,i)=a/1000;
% v(:,k,i)=R(:,:,i)*randn(2,1);%产生各个观测站的测量噪声
end
end
%生成目标状态和测量值
for k=1:step
for i=1:NT
if k==1
x(:,k,i)=fai*x0(:,i)+w(:,k,i);%生成目标i的状态
else
x(:,k,i)=fai*x(:,k-1,i)+w(:,k-1,i);%生成目标i的状态
end
ra(k,i)=sqrt(x(1,k,i)^2+x(3,k,i)^2)+v(1,k,1);%基阵A对目标i的距离
rb(k,i)=sqrt((x(1,k,i)-D)^2+x(3,k,i)^2)+v(1,k,2);%基阵B对目标i的距离
A(k,i)=acos(x(1,k,i)/ra(k,i))+v(2,k,1);%基阵A对目标i的测向角αi
B(k,i)=acos((x(1,k,i)-D)/rb(k,i))+v(2,k,2);%基阵B对目标i的测向角βi
za(:,k,i)=[ra(k,i);A(k,i)];%基阵A对目标i的量测
zb(:,k,i)=[rb(k,i);B(k,i)];%基阵B对目标i的量测
end
end
for k=1:step
for j=1:2
z1a(:,k,j)=[za(1,k,j)*cos(za(2,k,j));za(1,k,j)*sin(za(2,k,j))];%涉及基阵A的极坐标量测转换成直角坐标量测
z1b(:,k,j)=[zb(1,k,j)*cos(zb(2,k,j))+D;zb(1,k,j)*sin(zb(2,k,j))];%涉及基阵B的极坐标量测转换成直角坐标量测
end
end
%%%%%%%%最近邻域算法,NNSF
%%%%%目标1的关联情况
for k=1:step
if k==1
x1_yc(:,k)=fai*x0(:,1);
p1_yc(:,:,k)=fai*p0(:,:,1)*fai'+Q(:,:,1);
for i=1:2 %%%分别考察两个观测基站
if i==1
H1(:,:,k,i)=[x1_yc(1,k)/(x1_yc(1,k)^2+x1_yc(3,k)^2),0,x1_yc(3,k)/(x1_yc(1,k)^2+x1_yc(3,k)^2),0;-x1_yc(3,k)/(x1_yc(1,k)^2+x1_yc(3,k)^2),0,x1_yc(1,k)/(x1_yc(1,k)^2+x1_yc(3,k)^2),0];
z1_yc(:,k,i)=[sqrt(x1_yc(1,k)^2+x1_yc(3,k)^2);acos(x1_yc(1,k)/sqrt(x1_yc(1,k)^2+x1_yc(3,k)^2))];
S1(:,:,k,i)=H1(:,:,k,i)*p1_yc(:,:,k)*H1(:,:,k,i)'+R(:,:,i)*R(:,:,i);
K1(:,:,k,i)=p1_yc(:,:,k)*H1(:,:,k,i)'*inv(S1(:,:,k,i));
x1_gj(:,k,i)=x1_yc(:,k)+K1(:,:,k,i)*(za(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,k,i)'+R(:,:,i)*R(:,:,i);
K1(:,:,k,i)=p1_yc(:,:,k)*H1(:,:,k,i)'*inv(S1(:,:,k,i));
x1_gj(:,k,i)=x1_yc(:,k)+K1(:,:,k,i)*(zb(:,k,1)-z1_yc(:,k,i));
p1_gj(:,:,k,i)=(I-K1(:,:,k,i)*H1(:,:,k,i))*p1_yc(:,:,k);
end
end
%%%融合
p1_cross(:,:,k)=(I-K1(:,:,k,1)*H1(:,:,k,1))*(fai*p1_cross(:,:,k-1)*fai'+Q(:,:,1))*(I-K1(:,:,k,2)*H1(:,:,k,2))';
L1(:,:,k)=(p1_gj(:,:,1)-p1_cross(:,:,k))*inv(p1_gj(:,:,1)+p1_gj(:,:,2)-p1_cross(:,:,k)-p1_cross(:,:,k)');
X1_gj(:,k)=x1_gj(:,k,1)+L1(:,:,k)*(x1_gj(:,k,2)-x1_gj(:,k,1));
P1_gj(:,:,k)=p1_gj(:,:,k,1)-L1(:,:,k)*(p1_gj(:,:,k,1)-p1_cross(:,:,k)');
% X1_gj(:,k)=inv(p1_gj(:,:,k,1))*x1_gj(:,k,1)+inv(p1_gj(:,:,k,2))*x1_gj(:,k,2)-p1_yc(:,:,k)*x1_yc(:,k);
% P1_gj(:,:,k)=inv(inv(p1_gj(:,:,k,1))+inv(p1_gj(:,:,k,2))-inv(p1_yc(:,:,k)));
end
end
%%%%%目标2的关联情况
for k=1:step
if k==1
x2_yc(:,k)=fai*x0(:,2);
p2_yc(:,:,k)=fai*p0(:,:,2)*fai'+Q(:,:,2);
for i=1:2 %%%分别考察两个观测基站
if i==1
H2(:,:,k,i)=[x2_yc(1,k)/(x2_yc(1,k)^2+x2_yc(3,k)^2),0,x2_yc(3,k)/(x2_yc(1,k)^2+x2_yc(3,k)^2),0;-x2_yc(3,k)/(x2_yc(1,k)^2+x2_yc(3,k)^2),0,x2_yc(1,k)/(x2_yc(1,k)^2+x2_yc(3,k)^2),0];
z2_yc(:,k,i)=[sqrt(x2_yc(1,k)^2+x2_yc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