-
Notifications
You must be signed in to change notification settings - Fork 2
/
Standard_PDAF.m
80 lines (63 loc) · 2.68 KB
/
Standard_PDAF.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function [TrackList]=Standard_PDAF(TrackList)
for i=1:size(TrackList,2) %Need any track, witghout it, it won't run
if TrackList{i}.perish ~= 1
% extract track coordinates and covariance
x = TrackList{i}.x;
P = TrackList{i}.P;
F = TrackList{i}.F;
H = TrackList{i}.H;
Q = TrackList{i}.Q;
R = TrackList{i}.R;
% make prediction
xpred = F*x;
Ppred = F*P*F' + Q;
zpred = H*xpred;
S_tmp = H*Ppred*H' + R;
S = (S_tmp + S_tmp.') / 2; %% For Positive definite / Symmetric / Square
%--------------Process the measurements and do Probabilistic Data Association
if isempty(TrackList{i}.Measurement)
z=zpred; %No measurement case
v=zeros(size(z,1),1);
%For Probability Data Association
Beta_0=1; %switching value
%Calc Kalman gain
K=(Ppred*H')/(H*Ppred*H'+R);
P_c=Ppred-K*S*K';
P_tilda=0;
else
z=TrackList{i}.Measurement;
%For Probability Data Association
Beta=[]; LR=[]; Sum_LR=0; v=zeros(size(z,1),1); Beta_0=0; %switching value
%Calc LR
for j=1:size(TrackList{i}.Measurement,2)
LR(j)=mvnpdf(z(:,j),zpred,S);
%The error may occur on 'mvnpdf' : SIGMA must be a square, symmetric, positive definite matrix.
Sum_LR=Sum_LR+LR(j);
end
%Calc Beta
for j=1:size(TrackList{i}.Measurement,2)
Beta(j)=LR(j)/Sum_LR;
end
%Calc Combined Innovation
for j=1:size(TrackList{i}.Measurement,2)
v=v+Beta(j)*(z(:,j)-zpred);
end
%Calc Kalman gain
K=(Ppred*H')/(H*Ppred*H'+R);
P_c=Ppred-K*S*K';
%----------------for Ptilda------------
Spread_of_Innovations_temp=0;
for j=1:size(TrackList{i}.Measurement,2)
v_l=(z(:,j)-zpred);
Spread_of_Innovations_temp=Spread_of_Innovations_temp+(Beta(j)*(v_l*v_l'));
end
P_tilda=K*(Spread_of_Innovations_temp-v*v')*K';
end
x=xpred+K*v;
%----------------------------------------------
P=Beta_0*Ppred+(1-Beta_0)*P_c+P_tilda;
%----------------------------------------------
TrackList{i}.x=x; %Parameter Update
TrackList{i}.P=P;
end
end