ControlDesign

 Kalman
 design Kalman estimator for a given state-space system

 Calling Sequence Kalman(sys, G, H, Q, R, opts)

Parameters

 sys - System; system object G - Matrix; process noise matrix in the state equations H - Matrix: process noise matrix in the output equations Q - Matrix; process noise covariance matrix R - Matrix; measurement noise covariance matrix opts - (optional) equation(s) of the form option = value; specify options for the Kalman command

Options

 • N = Matrix or Vector
 The cross-correlation matrix between process and measurement noises. If omitted, a zero matrix with appropriate dimensions will be considered.
 • output = gain or filter
 Specifies whether the Kalman gains or the Kalman filter object must be returned. The default value is gain.
 If gain, the Kalman gains and steady state estimation error covariance matrices are returned as follows:
 – In the continuous-time domain, the gain matrix and steady state error covariance are returned as a sequence of $L,P$ where $L$ and $P$ are as defined before.
 – In the discrete-time domain, the gain matrix, the innovation gain, and the steady state error covariance matrices are returned as a sequence of $L,M,P,Z$ where $L$, $P$, and $M$ are as defined before and
 $Z=\underset{n\to \infty }{lim}E\left\{e\left[n{|}n\right]e{\left[n{|}n\right]}^{T}\right\}=\left(I-\mathrm{MC}\right)P,e\left[n{|}n\right]=x\left[n\right]-\stackrel{ˆ}{x}\left[n{|}n\right]$.
 If filter, the Kalman filter is returned as a state-space DynamicSystems object. The structure of the filter depends on the time-domain and the value of option filtertype (for the discrete Kalman filter).
 • filtertype =  current or delayed
 Specifies the type of the discrete Kalman filter. The default value is current.
 • parameters = {list, set}(name = complexcons)
 Specifies numeric values for the parameters of sys. These values override any parameters previously specified for sys. The numeric value on the right-hand side of each equation is substituted for the name on the left-hand side in the sys equations. The default is the value of sys given by DynamicSystems:-SystemOptions(parameters).

Solvability Conditions

 • The pair $\left(A,C\right)$ must be detectable.
 • The pair $\left(A-\stackrel{_}{N}{\stackrel{_}{R}}^{-1}C,\stackrel{_}{Q}-\stackrel{_}{N}{\stackrel{_}{R}}^{-1}{\stackrel{_}{N}}^{T}\right)$ must have no uncontrollable modes on the imaginary axis in continuous-time domain or on the unit circle in discrete-time domain

where $\stackrel{_}{Q}={\mathrm{GQG}}^{T}$, $\stackrel{_}{R}$, and $\stackrel{_}{N}$ are as defined before.

 • $\stackrel{_}{R}>0$ (positive definite) and $\stackrel{_}{Q}-\stackrel{_}{N}{\stackrel{_}{R}}^{-1}{\stackrel{_}{N}}^{T}\ge 0$ (positive semidefinite)

where $\stackrel{_}{Q}$, $\stackrel{_}{R}$, and $\stackrel{_}{N}$ are as defined before.

Description

 • The Kalman command designs the Kalman estimator for a given system and process and measurement noise covariance matrices.
 • The system sys is a continuous or discrete-time linear system object created using the DynamicSystems package. The system object must be in state-space (SS) form.
 • If sys contains structural uncontrollable or unobservable states, they are removed using ReduceSystem before computing the Kalman gains.  The resulting Kalman gains are then filled with zeros at positions corresponding to the removed states.

 • Continuous-Time Kalman Estimator (Filter)

Given the continuous-time system

$\stackrel{\cdot }{x}=\mathrm{Ax}+\mathrm{Bu}+\mathrm{Gw}$

$y=\mathrm{Cx}+\mathrm{Du}+\mathrm{Hw}+v$

with known (deterministic) inputs $u$, white process noise $w$, and white measurement noise $v$, satisfying

$E\left\{w\right\}=0$    (process noise has zero mean value)

$E\left\{v\right\}=0$    (measurement noise has zero mean value)

$E\left\{w{w}^{T}\right\}=Q$

$E\left\{v{v}^{T}\right\}=R$

$E\left\{w{v}^{T}\right\}=N$

where $E\left\{a\right\}$ is the mathematical expectation of $a$, the Kalman filter provides an optimal state estimation that minimizes the steady state error covariance

$P=\underset{t\to \infty }{lim}E\left\{\left(x-\stackrel{ˆ}{x}\right){\left(x-\stackrel{ˆ}{x}\right)}^{T}\right\}$.

The Kalman filter equations are given as

$\stackrel{\cdot }{\stackrel{ˆ}{x}}=A\stackrel{ˆ}{x}+\mathrm{Bu}+L\left(y-C\stackrel{ˆ}{x}-\mathrm{Du}\right)$

$\left[\begin{array}{c}\stackrel{^}{x}\\ \stackrel{^}{y}\end{array}\right]=\left[\begin{array}{c}I\\ C\end{array}\right]\stackrel{^}{x}+\left[\begin{array}{cc}0& 0\\ \mathrm{D}& 0\end{array}\right]\left[\begin{array}{c}u\\ y\end{array}\right]$.

The gain matrix $L$ is calculated as

$L=\left(P{C}^{T}+\stackrel{_}{N}\right){\stackrel{_}{R}}^{-1}$

where $P$ is the solution of the corresponding algebraic Riccati equation and

$\stackrel{_}{R}=R+\mathrm{HN}+{\left(\mathrm{HN}\right)}^{T}+\mathrm{HQ}{H}^{T}$

$\stackrel{_}{N}=G\left({\mathrm{QH}}^{T}+N\right)$.

 • Discrete-Time Kalman Estimator (Filter)

Given the discrete-time system

$x\left[n+1\right]=\mathrm{Ax}\left[n\right]+\mathrm{Bu}\left[n\right]+\mathrm{Gw}\left[n\right]$

$y\left[n\right]=\mathrm{Cx}\left[n\right]+\mathrm{Du}\left[n\right]+\mathrm{Hw}\left[n\right]+v\left[n\right]$

and the noise covariance data

$E\left\{w\left[n\right]\right\}=0$

$E\left\{v\left[n\right]\right\}=0$

$E\left\{w\left[n\right]{w\left[n\right]}^{T}\right\}=Q$

$E\left\{v\left[n\right]{v\left[n\right]}^{T}\right\}=R$

$E\left\{w\left[n\right]{v\left[n\right]}^{T}\right\}=N$

the Kalman filter provides an optimal state estimation that minimizes the steady state error covariance

$P=\underset{n\to \infty }{lim}E\left\{e\left[n{|}n-1\right]e{\left[n{|}n-1\right]}^{T}\right\},e\left[n{|}n-1\right]=x\left[n\right]-\stackrel{ˆ}{x}\left[n{|}n-1\right]$.

The discrete Kalman filter state equation is given as

$\stackrel{ˆ}{x}\left[n+1|n\right]=A\stackrel{ˆ}{x}\left[n|n-1\right]+\mathrm{Bu}\left[n\right]+L\left(y\left[n\right]-C\stackrel{ˆ}{x}\left[n|n-1\right]-\mathrm{Du}\left[n\right]\right)$

The gain matrix $L$ is calculated as

$L=\left(\mathrm{AP}{C}^{T}+\stackrel{_}{N}\right){\left(\mathrm{CP}{C}^{T}+\stackrel{_}{R}\right)}^{-1}$

where  $P$ is the solution of the corresponding algebraic Riccati equation and $\stackrel{_}{R}$ and $\stackrel{_}{N}$ are as defined before.

 – The output equation structure depends on the type of the filter specified in the option filtertype:

 – The current estimator uses all available measurements up to $y\left[n\right]$ and generates state estimates $\stackrel{ˆ}{x}\left[n|n\right]$ and output estimates $\stackrel{ˆ}{y}\left[n|n\right]$. The updated estimates are obtained from the prediction $\stackrel{ˆ}{x}\left[n|n-1\right]$ using the latest measurement $y\left[n\right]$ as

$\stackrel{ˆ}{x}\left[n|n\right]=\stackrel{ˆ}{x}\left[n|n-1\right]+M\left(y\left[n\right]-C\stackrel{ˆ}{x}\left[n|n-1\right]-\mathrm{Du}\left[n\right]\right)$.

$y\left[n\right]-C\stackrel{ˆ}{x}\left[n|n-1\right]-\mathrm{Du}\left[n\right]$ is called the innovation signal which (under Kalman optimality conditions) is white.

The innovation gain, $M$, is given as

$M=P{C}^{T}{\left(\mathrm{CP}{C}^{T}+\stackrel{_}{R}\right)}^{-1}$.

The output equation is given as

$\left[\begin{array}{c}\stackrel{^}{x}\left[n|n\right]\\ \stackrel{^}{y}\left[n|n\right]\end{array}\right]=\left[\begin{array}{c}I-\mathrm{MC}\\ \left(I-\mathrm{CM}\right)C\end{array}\right]\stackrel{^}{x}\left[n|n-1\right]+\left[\begin{array}{cc}-\mathrm{MD}& M\\ \left(I-\mathrm{CM}\right)\mathrm{D}& \mathrm{CM}\end{array}\right]\left[\begin{array}{c}u\left[n\right]\\ y\left[n\right]\end{array}\right]$.

 – The delayed estimator uses measurements up to $y\left[\mathrm{n-1}\right]$ and generates state estimates $\stackrel{ˆ}{x}\left[n|\mathrm{n-1}\right]$ and output estimates $\stackrel{ˆ}{y}\left[n|\mathrm{n-1}\right]$.

The output equation is given as

$\left[\begin{array}{c}\stackrel{^}{x}\left[n|n-1\right]\\ \stackrel{^}{y}\left[n|n-1\right]\end{array}\right]=\left[\begin{array}{c}I\\ C\end{array}\right]\stackrel{^}{x}\left[n|n-1\right]+\left[\begin{array}{cc}0& 0\\ \mathrm{D}& 0\end{array}\right]\left[\begin{array}{c}u\left[n\right]\\ y\left[n\right]\end{array}\right]$.

Examples

 > $\mathrm{with}\left(\mathrm{ControlDesign}\right):$
 > $\mathrm{with}\left(\mathrm{DynamicSystems}\right):$

Design a Kalman filter for a continuous system

 > $\mathrm{csys}≔\mathrm{NewSystem}\left(\mathrm{Matrix}\left(\left[\left[\frac{1}{s+1},\frac{s}{{s}^{2}+3s+2}\right],\left[\frac{3}{\left(s+1\right)\left(s+4\right)},\frac{s}{{s}^{2}+1}\right]\right]\right)\right):$
 > $\mathrm{sys}≔\mathrm{StateSpace}\left(\mathrm{csys}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{sys}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{2 output\left(s\right); 2 input\left(s\right); 6 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({t}\right){,}{\mathrm{u2}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({t}\right){,}{\mathrm{y2}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{\mathrm{x1}}{}\left({t}\right){,}{\mathrm{x2}}{}\left({t}\right){,}{\mathrm{x3}}{}\left({t}\right){,}{\mathrm{x4}}{}\left({t}\right){,}{\mathrm{x5}}{}\left({t}\right){,}{\mathrm{x6}}{}\left({t}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{cccccc}{0}& {1}& {0}& {0}& {0}& {0}\\ {-4}& {-5}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {1}& {0}& {0}\\ {0}& {0}& {0}& {0}& {1}& {0}\\ {0}& {0}& {0}& {0}& {0}& {1}\\ {0}& {0}& {-2}& {-3}& {-3}& {-3}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{cc}{0}& {0}\\ {1}& {0}\\ {0}& {0}\\ {0}& {0}\\ {0}& {0}\\ {0}& {1}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cccccc}{4}& {1}& {0}& {1}& {0}& {1}\\ {3}& {0}& {0}& {2}& {3}& {1}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{cc}{0}& {0}\\ {0}& {0}\end{array}\right]\end{array}\right$ (1)
 > $G≔\mathrm{LinearAlgebra}:-\mathrm{IdentityMatrix}\left(6\right):$
 > $Q≔\frac{2\mathrm{LinearAlgebra}:-\mathrm{IdentityMatrix}\left(6\right)}{3}:$
 > $H≔\mathrm{Matrix}\left(\left[\left[1,0,0,1,2,-2\right],\left[0,3,5,7,-1,2\right]\right]\right):$
 > $R≔2\mathrm{LinearAlgebra}:-\mathrm{IdentityMatrix}\left(2\right):$
 > $\mathrm{Kgc}≔\mathrm{Kalman}\left(\mathrm{sys},G,H,Q,R\right):$
 > $\mathrm{Kgain}≔{\mathrm{Kgc}}_{1}$
 ${\mathrm{Kgain}}{:=}\left[\begin{array}{cc}{0.192433463634531}& {0.00614696476597994}\\ {-}{0.0643037043577344}& {0.0264039604378602}\\ {-}{0.0638163203438628}& {-}{0.0655169281432432}\\ {0.00978367900149663}& {0.0963473659292315}\\ {0.108484789016212}& {0.0909526847294459}\\ {-}{0.0254223506098090}& {0.0116225919671224}\end{array}\right]$ (2)
 > $\mathrm{Kcov}≔{\mathrm{Kgc}}_{2}$
 ${\mathrm{Kcov}}{:=}\left[\begin{array}{cccccc}{0.28619026502462421249216422557974673288293232592618}& {-}{0.17093249750486729793964027668869909748546520252115}& {-}{0.023090085729227154363628640070442235954898979569838}& {-}{0.19723589554649682144619488632748940798762022313999}& {-}{0.063829831128177815994146097916068876282064128595202}& {0.22859532762945828671415622539317735625002783932338}\\ {-}{0.17093249750486729793964027668869909748546520252115}& {0.19582591742182165967612470819388315902860811255798}& {0.057706881538749435965508378755301988692734248674966}& {0.12847648642595889565755005263308806727757128935525}& {-}{0.0016386017918392762807724156621809230998288592598214}& {-}{0.18026854463676903611658851547851644267659801796258}\\ {-}{0.023090085729227154363628640070442235954898979569838}& {0.057706881538749435965508378755301988692734248674966}& {3.3056011882889604243245501383529761632162692350168}& {-}{0.18269350977652883516212948916949839765570205397822}& {-}{2.1788360511969896530095223458096966715302998562266}& {-}{0.37940575725428501692384388757325100457563620518737}\\ {-}{0.19723589554649682144619488632748940798762022313999}& {0.12847648642595889565755005263308806727757128935525}& {-}{0.18269350977652883516212948916949839765570205397822}& {1.7859473284905272128326231780521898012234023009321}& {-}{0.050711404623049480966638606781444388971726417683354}& {-}{1.6431234374313737289058834295224106871103272678818}\\ {-}{0.063829831128177815994146097916068876282064128595202}& {-}{0.0016386017918392762807724156621809230998288592598214}& {-}{2.1788360511969896530095223458096966715302998562266}& {-}{0.050711404623049480966638606781444388971726417683354}& {2.1915085811133627110745889007046547886549312829194}& {-}{0.024827374445595292290923034042017137740920465257607}\\ {0.22859532762945828671415622539317735625002783932338}& {-}{0.18026854463676903611658851547851644267659801796258}& {-}{0.37940575725428501692384388757325100457563620518737}& {-}{1.6431234374313737289058834295224106871103272678818}& {-}{0.024827374445595292290923034042017137740920465257607}& {2.0297653609100465020733736810968951891825963803854}\end{array}\right]$ (3)
 > $\mathrm{LinearAlgebra}:-\mathrm{Eigenvalues}\left(\mathrm{sys}:-a-\mathrm{Kgain}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{sys}:-c\right)$
 $\left[\begin{array}{c}{-}{3.93877830228837}{+}{0.}{}{I}\\ {-}{2.47171603376280}{+}{0.}{}{I}\\ {-}{0.229038486136634}{+}{0.832844151778282}{}{I}\\ {-}{0.229038486136634}{-}{0.832844151778282}{}{I}\\ {-}{1.15841822127975}{+}{0.302560027651275}{}{I}\\ {-}{1.15841822127975}{-}{0.302560027651275}{}{I}\end{array}\right]$ (4)
 > $\mathrm{Kfilter}≔\mathrm{Kalman}\left(\mathrm{sys},G,H,Q,R,'\mathrm{output}'=\mathrm{filter}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{Kfilter}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{8 output\left(s\right); 4 input\left(s\right); 6 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({t}\right){,}{\mathrm{u2}}{}\left({t}\right){,}{\mathrm{y1}}{}\left({t}\right){,}{\mathrm{y2}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{x1_obs_out}}{}\left({t}\right){,}{\mathrm{x2_obs_out}}{}\left({t}\right){,}{\mathrm{x3_obs_out}}{}\left({t}\right){,}{\mathrm{x4_obs_out}}{}\left({t}\right){,}{\mathrm{x5_obs_out}}{}\left({t}\right){,}{\mathrm{x6_obs_out}}{}\left({t}\right){,}{\mathrm{y1}}{}\left({t}\right){,}{\mathrm{y2}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{\mathrm{x1_obs}}{}\left({t}\right){,}{\mathrm{x2_obs}}{}\left({t}\right){,}{\mathrm{x3_obs}}{}\left({t}\right){,}{\mathrm{x4_obs}}{}\left({t}\right){,}{\mathrm{x5_obs}}{}\left({t}\right){,}{\mathrm{x6_obs}}{}\left({t}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{cccccc}{-}{0.788174748836065}& {0.8075665363654687}& {0.0}& {-}{0.20472739316649116}& {-}{0.018440894297939818}& {-}{0.19858042840051124}\\ {-}{3.8219970638826433}& {-}{4.935696295642265}& {0.0}& {0.011495783482013966}& {-}{0.07921188131358059}& {0.03789974391987416}\\ {0.4518160658051807}& {0.06381632034386281}& {0.0}& {1.1948501766303492}& {0.19655078442972945}& {0.12933324848710598}\\ {-}{0.328176813793681}& {-}{0.009783679001496626}& {0.0}& {-}{0.20247841085995963}& {0.7109579022123055}& {-}{0.10613104493072813}\\ {-}{0.7067972102531872}& {-}{0.10848478901621239}& {0.0}& {-}{0.2903901584751042}& {-}{0.2728580541883377}& {0.8005625262543417}\\ {0.0668216265378687}& {0.025422350609808998}& {-}{2.0}& {-}{2.997822833324436}& {-}{3.0348677759013674}& {-}{2.9862002413573134}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{cccc}{0.0}& {0.0}& {0.1924334636345313}& {0.006146964765979939}\\ {1.0}& {0.0}& {-}{0.06430370435773436}& {0.026403960437860197}\\ {0.0}& {0.0}& {-}{0.06381632034386281}& {-}{0.06551692814324316}\\ {0.0}& {0.0}& {0.009783679001496626}& {0.0963473659292315}\\ {0.0}& {0.0}& {0.10848478901621239}& {0.0909526847294459}\\ {0.0}& {1.0}& {-}{0.025422350609808998}& {0.01162259196712243}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cccccc}{1}& {0}& {0}& {0}& {0}& {0}\\ {0}& {1}& {0}& {0}& {0}& {0}\\ {0}& {0}& {1}& {0}& {0}& {0}\\ {0}& {0}& {0}& {1}& {0}& {0}\\ {0}& {0}& {0}& {0}& {1}& {0}\\ {0}& {0}& {0}& {0}& {0}& {1}\\ {4.}& {1.}& {0.}& {1.}& {0.}& {1.}\\ {3.}& {0.}& {0.}& {2.}& {3.}& {1.}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{cccc}{0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0.}& {0.}& {0}& {0}\\ {0.}& {0.}& {0}& {0}\end{array}\right]\end{array}\right$ (5)

Design a Kalman filter for a discrete system:

 > $\mathrm{dsys}≔\mathrm{ToDiscrete}\left(\mathrm{csys},1,'\mathrm{method}'=\mathrm{bilinear}\right):$
 > $\mathrm{sys}≔\mathrm{StateSpace}\left(\mathrm{dsys}\right):$
 > $\mathrm{Kgc}≔\mathrm{Kalman}\left(\mathrm{sys},G,H,Q,R\right):$
 > $L≔{\mathrm{Kgc}}_{1}$
 ${L}{:=}\left[\begin{array}{cc}{0.102357348091063}& {-}{0.000270311689505002}\\ {-}{0.0000225872756644528}& {0.0316301696710112}\\ {0.0324778264960475}& {-}{0.0304093684912018}\\ {0.0704309874351989}& {-}{0.0320525532654381}\\ {0.129070756561783}& {-}{0.0489238268444825}\\ {-}{0.175506475598478}& {0.0836901687155676}\end{array}\right]$ (6)
 > $M≔{\mathrm{Kgc}}_{2}$
 ${M}{:=}\left[\begin{array}{cc}{0.0253685913778349}& {0.00580736350880106}\\ {0.0274697247286604}& {0.000676794860821479}\\ {-}{0.0218446273754245}& {0.00178225865532143}\\ {0.0372133592476799}& {-}{0.0820508802560722}\\ {0.00217310992508201}& {-}{0.103403563185930}\\ {-}{0.0216515967133475}& {-}{0.0367013113908555}\end{array}\right]$ (7)
 > $P≔{\mathrm{Kgc}}_{3}$
 ${P}{:=}\left[\begin{array}{cccccc}{1.1900369256390078377586184628370039668475331991448}& {-}{0.0023320086090345049249859938698105927722038641180531}& {0.0061998827422618221294455827872920780525874972897137}& {0.014704192484813023622580936656881320686092202865071}& {-}{0.26910475791320750804979073203338265728777922953550}& {-}{0.17883726222393262145311402911160312135949479177824}\\ {-}{0.0023320086090345049249859938698105927722038641180531}& {0.61670692397166809254217990688699410868842846313117}& {0.062957575000545940463224654738305222803191417153972}& {0.033808441060154514359741367661977779127934579497919}& {0.076819002446584818836921297831759174977385306740545}& {-}{0.15462446618098261544168174277522672775638325502978}\\ {0.0061998827422618221294455827872920780525874972897137}& {0.062957575000545940463224654738305222803191417153972}& {14.025849333821809856790922021450562508283629456859}& {7.4346881925078578276089838791018867254508860879170}& {-}{3.5696824762744547720904033319872007356676381302352}& {-}{11.113108157713765146316160035522758848528561725755}\\ {0.014704192484813023622580936656881320686092202865071}& {0.033808441060154514359741367661977779127934579497919}& {7.4346881925078578276089838791018867254508860879170}& {13.426727719234365542941496863071620708460198331150}& {7.5154613955186568085059467231836511906099352421786}& {-}{3.4406863305018803177987802662013206227436745305880}\\ {-}{0.26910475791320750804979073203338265728777922953550}& {0.076819002446584818836921297831759174977385306740545}& {-}{3.5696824762744547720904033319872007356676381302352}& {7.5154613955186568085059467231836511906099352421786}& {12.866972987719699209572339910279283446718950849439}& {7.6916211935162691687987582863169769663886962498825}\\ {-}{0.17883726222393262145311402911160312135949479177824}& {-}{0.15462446618098261544168174277522672775638325502978}& {-}{11.113108157713765146316160035522758848528561725755}& {-}{3.4406863305018803177987802662013206227436745305880}& {7.6916211935162691687987582863169769663886962498825}& {12.493137943161183557844150615741546706412859530872}\end{array}\right]$ (8)
 > $Z≔{\mathrm{Kgc}}_{4}$
 ${Z}{:=}\left[\begin{array}{cccccc}{1.18188087156736}& {-}{0.00894129364051063}& {0.0105368060799054}& {0.0386074205259520}& {-}{0.228656565276868}& {-}{0.159304648350176}\\ {-}{0.00894129364051063}& {0.609921640852156}& {0.0681998217561377}& {0.0301077499423651}& {0.0831297099445528}& {-}{0.146882483807686}\\ {0.0105368060799054}& {0.0681998217561377}& {14.0214547359271}& {7.44986437129508}& {-}{3.55919924152385}& {-}{11.1137202048741}\\ {0.0386074205259520}& {0.0301077499423651}& {7.44986437129508}& {12.9843151713309}& {6.96975114659318}& {-}{3.62844349992178}\\ {-}{0.228656565276868}& {0.0831297099445528}& {-}{3.55919924152385}& {6.96975114659318}& {12.1763352407015}& {7.44503056330966}\\ {-}{0.159304648350176}& {-}{0.146882483807686}& {-}{11.1137202048741}& {-}{3.62844349992178}& {7.44503056330966}& {12.4006152930078}\end{array}\right]$ (9)
 > $\mathrm{LinearAlgebra}:-\mathrm{Eigenvalues}\left(\mathrm{sys}:-a-L\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{sys}:-c\right)$
 $\left[\begin{array}{c}{0.557923700713316}{+}{0.764621079517395}{}{I}\\ {0.557923700713316}{-}{0.764621079517395}{}{I}\\ {-}{0.329933413527070}{+}{0.}{}{I}\\ {0.313799486006446}{+}{0.}{}{I}\\ {0.178331258920455}{+}{0.146122594396005}{}{I}\\ {0.178331258920455}{-}{0.146122594396005}{}{I}\end{array}\right]$ (10)
 > $\mathrm{Kfilter}≔\mathrm{Kalman}\left(\mathrm{sys},G,H,Q,R,'\mathrm{output}'=\mathrm{filter},'\mathrm{filtertype}'=\mathrm{current}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{Kfilter}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{discrete; sampletime = 1}}\\ {\mathrm{8 output\left(s\right); 4 input\left(s\right); 6 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({q}\right){,}{\mathrm{u2}}{}\left({q}\right){,}{\mathrm{y1}}{}\left({q}\right){,}{\mathrm{y2}}{}\left({q}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{x1_obs_out}}{}\left({q}\right){,}{\mathrm{x2_obs_out}}{}\left({q}\right){,}{\mathrm{x3_obs_out}}{}\left({q}\right){,}{\mathrm{x4_obs_out}}{}\left({q}\right){,}{\mathrm{x5_obs_out}}{}\left({q}\right){,}{\mathrm{x6_obs_out}}{}\left({q}\right){,}{\mathrm{y1}}{}\left({q}\right){,}{\mathrm{y2}}{}\left({q}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{\mathrm{x1_obs}}{}\left({q}\right){,}{\mathrm{x2_obs}}{}\left({q}\right){,}{\mathrm{x3_obs}}{}\left({q}\right){,}{\mathrm{x4_obs}}{}\left({q}\right){,}{\mathrm{x5_obs}}{}\left({q}\right){,}{\mathrm{x6_obs}}{}\left({q}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{cccccc}{-}{0.01511399384383529}& {0.954597949193903}& {0.017059558018589018}& {-}{0.02608590584394377}& {0.023623881995911238}& {-}{0.00555676972788489}\\ {0.10525701853462668}& {-}{0.010533351100099547}& {-}{0.0000037645459448283698}& {-}{0.008428939609542085}& {0.03035969251984984}& {-}{0.015181226593437272}\\ {0.0008198346861556889}& {-}{0.004298133389635165}& {0.00541297108375718}& {0.999809275937123}& {-}{0.021614834236891853}& {0.012792173181407632}\\ {-}{0.004498562344786059}& {-}{0.02061847665843606}& {0.011738497908214178}& {-}{0.009451682586940284}& {0.9856634459310448}& {0.011472392931808444}\\ {-}{0.010061625623605918}& {-}{0.041056838408526135}& {0.021511792764599608}& {-}{0.01993839507803279}& {-}{0.01685036391058944}& {1.0163128392980123}\\ {0.010502779946460792}& {0.05010615513356839}& {-}{0.029251079272263295}& {0.35586760985602595}& {-}{1.3606089490001831}& {1.5029124117727788}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{cccc}{-}{0.03407406407868246}& {-}{0.016951433342787016}& {0.10235734809106264}& {-}{0.000270311689505002}\\ {0.9947358341456645}& {-}{0.01264830332245967}& {-}{0.000022587275664452764}& {0.031630169671011246}\\ {-}{0.005757714081385973}& {0.0067507763127235216}& {0.03247782649604752}& {-}{0.030409368491201752}\\ {-}{0.018134903597410486}& {0.0010825233979610705}& {0.07043098743519888}& {-}{0.03205255326543812}\\ {-}{0.034869614373914254}& {-}{0.0019422620268065953}& {0.1290707565617835}& {-}{0.04892382684448253}\\ {0.04455379707159167}& {0.9957750117860362}& {-}{0.17550647559847848}& {0.0836901687155676}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cccccc}{0.9951662524805671}& {-}{0.013210717336205916}& {0.004228098563818108}& {-}{0.008031714733559169}& {0.011494406955764879}& {-}{0.004196900671994753}\\ {-}{0.004194921229011449}& {0.9875656351682317}& {0.004578287455692393}& {-}{0.0072005193947868255}& {0.007059325502160392}& {-}{0.0018509573515753095}\\ {0.0029061931924437047}& {0.009114637058614516}& {0.9963592287700345}& {0.005107246910989794}& {-}{0.0033861114110956625}& {0.0003581062552886078}\\ {0.009681517198919954}& {0.01081102264086298}& {0.006202226542520433}& {1.0123701540394043}& {-}{0.07008572788927772}& {0.03731701367565591}\\ {0.018826865787907758}& {0.03350202775859008}& {0.000362184987586106}& {0.02701893320541063}& {0.9012396383239537}& {0.04951298200006561}\\ {0.01000418310348892}& {0.02185670233403171}& {-}{0.003608599452946302}& {0.015320202199824827}& {-}{0.04028529816761396}& {1.0188194959517818}\\ {0.14372028049668745}& {0.43160174887495234}& {-}{0.1620986662259175}& {0.24802219946155157}& {-}{0.22503341315657846}& {0.05308052899453921}\\ {0.1722016943475244}& {0.3079543257299741}& {0.0018831787867113346}& {0.2474933679112119}& {-}{0.8987348209695748}& {0.4500579093728716}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{cccc}{-}{0.009424091043426445}& {-}{0.006551043967338532}& {0.02536859137783493}& {0.005807363508801058}\\ {-}{0.00926937405213062}& {-}{0.004849005400020985}& {0.027469724728660414}& {0.0006767948608214791}\\ {0.00698449934846704}& {0.002927867767837003}& {-}{0.021844627375424527}& {0.0017822586553214303}\\ {0.0012706936307608583}& {0.026618125559908428}& {0.03721335924767993}& {-}{0.08205088025607216}\\ {0.016509557226146918}& {0.04099924028678598}& {0.002173109925082014}& {-}{0.1034035631859302}\\ {0.013334084136760068}& {0.018289124009288497}& {-}{0.021651596713347494}& {-}{0.03670131139085549}\\ {0.3238666518889023}& {0.16130503310845973}& {0.027408002839013318}& {0.0019840827936444677}\\ {0.15272171038783589}& {0.3736881842424832}& {0.011299072718008193}& {0.06107159242701374}\end{array}\right]\end{array}\right$ (11)
 > $\mathrm{Kfilter}≔\mathrm{Kalman}\left(\mathrm{sys},G,H,Q,R,'\mathrm{output}'=\mathrm{filter},'\mathrm{filtertype}'=\mathrm{delayed}\right):$
 > $\mathrm{PrintSystem}\left(\mathrm{Kfilter}\right)$
 $\left[\begin{array}{l}{\mathbf{State Space}}\\ {\mathrm{discrete; sampletime = 1.}}\\ {\mathrm{8 output\left(s\right); 4 input\left(s\right); 6 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({q}\right){,}{\mathrm{u2}}{}\left({q}\right){,}{\mathrm{y1}}{}\left({q}\right){,}{\mathrm{y2}}{}\left({q}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{x1_obs_out}}{}\left({q}\right){,}{\mathrm{x2_obs_out}}{}\left({q}\right){,}{\mathrm{x3_obs_out}}{}\left({q}\right){,}{\mathrm{x4_obs_out}}{}\left({q}\right){,}{\mathrm{x5_obs_out}}{}\left({q}\right){,}{\mathrm{x6_obs_out}}{}\left({q}\right){,}{\mathrm{y1}}{}\left({q}\right){,}{\mathrm{y2}}{}\left({q}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{\mathrm{x1_obs}}{}\left({q}\right){,}{\mathrm{x2_obs}}{}\left({q}\right){,}{\mathrm{x3_obs}}{}\left({q}\right){,}{\mathrm{x4_obs}}{}\left({q}\right){,}{\mathrm{x5_obs}}{}\left({q}\right){,}{\mathrm{x6_obs}}{}\left({q}\right)\right]\\ {\mathrm{a}}{=}\left[\begin{array}{cccccc}{-}{0.01511399384383529}& {0.954597949193903}& {0.017059558018589018}& {-}{0.02608590584394377}& {0.023623881995911238}& {-}{0.00555676972788489}\\ {0.10525701853462668}& {-}{0.010533351100099547}& {-}{0.0000037645459448283698}& {-}{0.008428939609542085}& {0.03035969251984984}& {-}{0.015181226593437272}\\ {0.0008198346861556889}& {-}{0.004298133389635165}& {0.00541297108375718}& {0.999809275937123}& {-}{0.021614834236891853}& {0.012792173181407632}\\ {-}{0.004498562344786059}& {-}{0.02061847665843606}& {0.011738497908214178}& {-}{0.009451682586940284}& {0.9856634459310448}& {0.011472392931808444}\\ {-}{0.010061625623605918}& {-}{0.041056838408526135}& {0.021511792764599608}& {-}{0.01993839507803279}& {-}{0.01685036391058944}& {1.0163128392980123}\\ {0.010502779946460792}& {0.05010615513356839}& {-}{0.029251079272263295}& {0.35586760985602595}& {-}{1.3606089490001831}& {1.5029124117727788}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{cccc}{-}{0.03407406407868246}& {-}{0.016951433342787016}& {0.10235734809106264}& {-}{0.000270311689505002}\\ {0.9947358341456645}& {-}{0.01264830332245967}& {-}{0.000022587275664452764}& {0.031630169671011246}\\ {-}{0.005757714081385973}& {0.0067507763127235216}& {0.03247782649604752}& {-}{0.030409368491201752}\\ {-}{0.018134903597410486}& {0.0010825233979610705}& {0.07043098743519888}& {-}{0.03205255326543812}\\ {-}{0.034869614373914254}& {-}{0.0019422620268065953}& {0.1290707565617835}& {-}{0.04892382684448253}\\ {0.04455379707159167}& {0.9957750117860362}& {-}{0.17550647559847848}& {0.0836901687155676}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cccccc}{1}& {0}& {0}& {0}& {0}& {0}\\ {0}& {1}& {0}& {0}& {0}& {0}\\ {0}& {0}& {1}& {0}& {0}& {0}\\ {0}& {0}& {0}& {1}& {0}& {0}\\ {0}& {0}& {0}& {0}& {1}& {0}\\ {0}& {0}& {0}& {0}& {0}& {1}\\ {0.1481481481}& {0.4444444444}& {-0.1666666667}& {0.2555555556}& {-0.2333333333}& {0.05555555556}\\ {0.1851851852}& {0.3333333333}& {0.}& {0.2666666667}& {-0.9600000000}& {0.4800000000}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{cccc}{0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0.3333333333}& {0.1666666667}& {0}& {0}\\ {0.1666666667}& {0.4000000000}& {0}& {0}\end{array}\right]\end{array}\right$ (12)

References

 [1] F. Lewis, Optimal Estimation, John Wiley & Sons, 1986.
 [2] G. F. Franklin, J. D. Powell and M. L. Workman, Digital Control of Dynamic Systems, 2nd Ed., Addison-Wesley, 1990.