Problem with validation of the covariance matrix P in the steady state continuous Kalman filter
Hi I am trying to verify on simulations that the covariance matrix of the estimation errror is equal to the matrix P provided by the Riccati Solution of a continuous kalman filter. However when I use lsim to simulate and get the covariance of the estimator error vectors the results are different from P. But if I do P*Ts I can see the equivalence.
Why this factor Ts is appearing?
I am using the following code:
clear
close all
clc
% System
A = [-10 -20;35 -50];
B = [1; 1;];
C = [1 0];
D = 0;
Fs = 50000; % Frequency
Ts = 1/Fs; %
t = 0:Ts:10;
L = length(t);
W = [20 0;0 10];
V = 1;
rng(10,’twister’);
w = chol(W, ‘lower’)*randn(2,L);
v = chol(V, ‘lower’)*randn(1,L);
mw = mean(w,2);
mv = mean(v);
v = v – mean(v)*ones(1,length(v));
w = w – mw.*ones(2,length(v));
cov_w = cov(w’);
cov_v = cov(v);
[Lk,P] = lqe(A,eye(2),C,W,V);
% Augmented system with plant and Kalman filter
Aak = [A zeros(2,2); Lk*C A-Lk*C];
Bak = [B eye(2) zeros(2,1); B zeros(2,2) Lk];
sys_obs_mak = ss(Aak,Bak,eye(4),0);
u(1,:) = 1*heaviside(t);
[yk,t,xk] = lsim(sys_obs_mak,[u’ w’ v’],t,[0 0 0 0]); % Simulation
erro = xk(:,1:2)-xk(:,3:4);
cov_erro_lsim = cov(erro)
PTs = P*Ts
PHi I am trying to verify on simulations that the covariance matrix of the estimation errror is equal to the matrix P provided by the Riccati Solution of a continuous kalman filter. However when I use lsim to simulate and get the covariance of the estimator error vectors the results are different from P. But if I do P*Ts I can see the equivalence.
Why this factor Ts is appearing?
I am using the following code:
clear
close all
clc
% System
A = [-10 -20;35 -50];
B = [1; 1;];
C = [1 0];
D = 0;
Fs = 50000; % Frequency
Ts = 1/Fs; %
t = 0:Ts:10;
L = length(t);
W = [20 0;0 10];
V = 1;
rng(10,’twister’);
w = chol(W, ‘lower’)*randn(2,L);
v = chol(V, ‘lower’)*randn(1,L);
mw = mean(w,2);
mv = mean(v);
v = v – mean(v)*ones(1,length(v));
w = w – mw.*ones(2,length(v));
cov_w = cov(w’);
cov_v = cov(v);
[Lk,P] = lqe(A,eye(2),C,W,V);
% Augmented system with plant and Kalman filter
Aak = [A zeros(2,2); Lk*C A-Lk*C];
Bak = [B eye(2) zeros(2,1); B zeros(2,2) Lk];
sys_obs_mak = ss(Aak,Bak,eye(4),0);
u(1,:) = 1*heaviside(t);
[yk,t,xk] = lsim(sys_obs_mak,[u’ w’ v’],t,[0 0 0 0]); % Simulation
erro = xk(:,1:2)-xk(:,3:4);
cov_erro_lsim = cov(erro)
PTs = P*Ts
P Hi I am trying to verify on simulations that the covariance matrix of the estimation errror is equal to the matrix P provided by the Riccati Solution of a continuous kalman filter. However when I use lsim to simulate and get the covariance of the estimator error vectors the results are different from P. But if I do P*Ts I can see the equivalence.
Why this factor Ts is appearing?
I am using the following code:
clear
close all
clc
% System
A = [-10 -20;35 -50];
B = [1; 1;];
C = [1 0];
D = 0;
Fs = 50000; % Frequency
Ts = 1/Fs; %
t = 0:Ts:10;
L = length(t);
W = [20 0;0 10];
V = 1;
rng(10,’twister’);
w = chol(W, ‘lower’)*randn(2,L);
v = chol(V, ‘lower’)*randn(1,L);
mw = mean(w,2);
mv = mean(v);
v = v – mean(v)*ones(1,length(v));
w = w – mw.*ones(2,length(v));
cov_w = cov(w’);
cov_v = cov(v);
[Lk,P] = lqe(A,eye(2),C,W,V);
% Augmented system with plant and Kalman filter
Aak = [A zeros(2,2); Lk*C A-Lk*C];
Bak = [B eye(2) zeros(2,1); B zeros(2,2) Lk];
sys_obs_mak = ss(Aak,Bak,eye(4),0);
u(1,:) = 1*heaviside(t);
[yk,t,xk] = lsim(sys_obs_mak,[u’ w’ v’],t,[0 0 0 0]); % Simulation
erro = xk(:,1:2)-xk(:,3:4);
cov_erro_lsim = cov(erro)
PTs = P*Ts
P kalman filter MATLAB Answers — New Questions