Changeset 8 for matlab/testKF.m

Show
Ignore:
Timestamp:
01/23/08 11:32:31 (16 years ago)
Author:
smidl
Message:

Kalmany funkci, PF nefunkci

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • matlab/testKF.m

    r7 r8  
    1111 
    1212N =1000; 
     13mu0 = [0;0]; 
     14P0 = 200*eye(2); 
    1315 
    1416u = ones(1,N); 
     
    2426 
    2527d=[y;u]; 
    26 itsave('testKF.it',d) 
     28itsave('testKF.it',d,A,B,C,D,Q,R,P0,mu0) 
     29save testKF 
    2730else 
    2831%!cd ../testKF 
    2932 
     33load testKF 
    3034% init  
    31 mu = [0;0]; 
    32 P = 200*eye(2); 
     35mu = mu0; 
     36P = P0; 
     37EP = [0;0]; 
    3338 
    3439for t=2:N 
     
    4146        K = P*C'*iRy;  
    4247        P = P- K*C*P; % P = P -KCP; 
     48        EP(:,t) = eig(P);  
     49        if any(EP<0), keyboard; end 
    4350        mu = mu + K*(y(t)-C*mu-D*u(t)); 
    4451        Mu(1:2,t)=mu; 
     
    5360hold on 
    5461plot(xth','--'); 
     62plot(xth2','+'); 
    5563plot(Mu',':'); 
    5664end