|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
卡尔曼滤波仿真程序用于匀速运动的目标跟踪. u/ S6 G) o* i) n4 b
3 X3 V9 l0 y0 K- k( M) e% kalman filtering( N" h j$ H6 Z! E( j6 y+ f3 H: a
x5 G( T4 s9 _- r5 N. l; d
load initial_track s; % y:initial data,s:data with noise. R- [; z' q4 C, W' K
T=0.1;
+ N/ @' p, h `( [+ ]# @, @5 g: _5 q- r& R7 q
% yp denotes the sample value of position
: G+ a2 [8 Q8 e' Y% yv denotes the sample value of velocity+ M% b5 Q! g, r% v1 j
% Y=[yp(n);yv(n)];
6 l, W& [7 G! R% error deviation caused by the random acceleration
3 x/ O& |6 a. g% known data+ [9 x- |1 d, L5 P( e+ F D
Y=zeros(2,200);$ }; M; I1 r) x% _0 o
Y0=[0;1];; Q4 i' }1 t9 I- k: o/ q- N
Y(:,1)=Y0;
: \5 Z& f( n; \% D# |A=[1 T
3 j0 X4 B! _- x! e 0 1]; % ~+ R o% e: z0 r& L! q
B=[1/2*(T)^2 T]';
; M# ~4 E# B/ g- y* P1 m+ A. XH=[1 0];
6 \5 }" R& g' }' R$ O5 I: }
$ a) M# O5 @- o9 G1 c1 bC0=[0 0 y. P6 i) x) v3 u. t6 s+ t. n
0 1];
) S, E1 ] g: t; g4 gC=[C0 zeros(2,2*199)];' {5 l1 s. h, T; c
Q=(0.25)^2;
6 R* M) ]2 ^/ i) \R=(0.25)^2;
2 u6 Z% A( P0 R
, O0 V% [# ~3 `& v# f S
7 ]8 X6 H6 c5 H; z% kalman algorithm ieration% J* ^7 s) z5 ]& I
for n=1:2008 C" ?1 k8 v& w( V# b3 a. I: s
i=(n-1)*2+1;3 x% ?; z0 R+ \' s2 c2 x6 u
K=C(:,i:i+1)*H'*inv(H*C(:,i:i+1)*H'+R);
: T/ P1 u* y8 B J8 h f* H8 f Y(:,n)=Y(:,n)+K*(s(:,n)-H*Y(:,n));. a& \. P" j/ J
Y(:,n+1)=A*Y(:,n);
' L. z0 a9 w! ~+ e: @* q' d2 T C(:,i:i+1)=(eye(2,2)-K*H)*C(:,i:i+1);
" \7 x/ R7 L! B8 r C(:,i+2:i+3)=A*C(:,i:i+1)*A'+B*Q*B';0 W; n( D8 Q: `2 S
end
, R! \# x" \1 I
# A8 e! I, z% `% ?% the diagram of position after filtering# Q/ g( p% n; }2 W9 Q. d
t=0:0.1:20;/ A& e' x& _2 d) G) K
figure(2);
8 S6 M' _! k( `yp=Y(1,:);1 Z" t/ [5 u5 G
plot(t,yp,'r.-');/ o* w5 F2 a- ?# l. W
axis([0 20 0 20]);+ t- ?* {" ^) E* y1 {6 ]5 N/ s! B
xlabel('time');1 e0 R4 m6 [5 R% v5 X
ylabel('yp position');: h# T: r7 V5 w# B
title('the track after kalman filtering');
/ ~# F8 q1 Z M- c1 n" ^hold on;7 B( d2 ~3 l8 I$ _" y+ A" l) v
8 }7 z3 a6 e# ?# n: o' r+ t( @
% the diagram of velocity after filtering- A) J) I K8 v) i' j! n+ A; E
figure(3);
( {( S6 U' [. E% Q Q; |yv=Y(2,:);
1 p) a. r" f! O6 e' P' Tplot(t,yv,'k.-');
/ P3 [, J; X) Q" ^+ z( Axlabel('time');
5 m( T) R* E8 X3 f( qylabel('yv velocity');
: H0 I* p s& A1 R5 I6 S2 G: ?9 g/ wtitle('the velocity caused by random acceleration');
# F* p5 P. v$ [% n- S6 g8 [. c) B, V
3 M) }: |; n6 X( l" Z" D7 y8 ^; p
& W1 s9 O& F" N. Z& V. L
6 ]! U9 a, H* B; r' v/ v- S0 R2 y
: u$ Z- Z% f2 P% Z |
|