A = [0 1; 0 0]; B = [0; 1]; C = [1 0]; D = 0; r0 = 10000; dr0 = -150; % initial conditions Sw = 900; % spectral density for disturbance Sv = 3600; % spectral density for noise Sigma_e_0 = [1e6 0; 0 4e5]; % covariance matrix for initial estimation error [Sigma_e_infinity,V,L] = care(A',C',B*Sw*B',Sv) L = L'; %% Building Kalman filter as a dynamic system Ak = (A-L*C); Bk = [B L]; F = ss(Ak,Bk(:,2),eye(2,2),zeros(2,1)) %% Designing Kalman filter using high level Matlab function KALMAN G = ss(A,B,C,D); [K,E,P] = kalman(G,Sw,Sv) K = K(2:3,:) %% Setting the simulation parameters tc = 0.1; piw = tc*Sw; piv = tc*Sv;