Changeset 32 for matlab/testKF.m
- Timestamp:
- 03/03/08 13:00:32 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
matlab/testKF.m
r22 r32 7 7 C=[1 0]; 8 8 D=[0]; 9 R=[ 0.1];9 R=[1]; 10 10 Q=[0.2 0 ; 0 0.02]; 11 11 … … 17 17 P0 = 200*eye(2); 18 18 19 u = ones(1,N);19 u = zeros(1,N); 20 20 x = zeros(2,N); 21 21 y = zeros(1,N); 22 22 23 23 x(:,1) = [10;10]; 24 Et = sQ*randn(2,N); 25 Wt = sR*randn(1,N); 24 26 for i=2:N; 25 et(1:2,i) = sQ*randn(2,1); 26 x(:,i) = A*x(:,i-1) + B*u(i) + et(:,i); 27 y(:,i) = C*x(:,i) + D*u(i) + sR*randn(1,1); 27 x(:,i) = A*x(:,i-1) + B*u(i) + Et(:,i); 28 y(:,i) = C*x(:,i) + D*u(i) + Wt(:,1); 28 29 end 29 30 … … 39 40 EP = [0;0]; 40 41 42 Oxt = mu0; 43 OPt = P0; 44 ll =0; 45 Oxt2 = mu0; 46 OPt2 = P0; 47 ll2=0; 48 49 41 50 for t=2:N 42 51 mu = A*mu + B*u(t); … … 50 59 mu = mu + K*(y(t)-C*mu-D*u(t)); 51 60 Mu(1:2,t)=mu; 61 62 [Oxt,OPt,ll(t)] = Kalman(Oxt,y(t),A,C,Q,R,OPt); 63 [Oxt2,OPt2,ll2(t)] = Kalman(Oxt2,y(t),A,C,Q,R/10000,OPt2); 52 64 end 65 66 keyboard 53 67 54 68 !cd ../;./tests/testKF