Azzera filtri
Azzera filtri

Problem with validation of the covariance matrix P in the steady state continuous Kalman filter

7 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Sudarsanan A K
Sudarsanan A K il 12 Giu 2024
Hello Luiz,
The factor "Ts" appears because you are comparing continuous-time Riccati solution outcomes with results from a discrete-time simulation. The continuous-time solution "P" from the Riccati equation represents error covariance in a continuous framework. When you simulate the system using "lsim", it discretizes the process, stepping through time in increments of "Ts", effectively transitioning to a discrete-time analysis.
This transition introduces "Ts" because discrete-time simulations spread the effect of continuous-time processes over discrete intervals. Hence, when you observe the error covariance from the simulation and compare it to "P", you need to account for this discretization interval, "Ts", to align the continuous-time predictions with discrete-time simulation results. That is why multiplying "P" by "Ts" makes the continuous-time solution comparable to your discrete-time simulation outcomes.
For better understanding of the algorithm used in "lsim" for discrete-time and continuous-time systems, refer to the algorithm section of the documentation:
I hope this helps!
  1 Commento
Luiz Maccari
Luiz Maccari il 14 Giu 2024
Hi, I understand that is occuring a discretization on LSIM. But why the covariance of the discrete error with a small Ts is not converging to the continuous P from Riccati Equation?
Thanks for the attention.

Accedi per commentare.

Prodotti


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by