design Kalman estimator for a given state-space system - MapleSim Help

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

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.00978367900149664}& {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.229038486136633}{+}{0.832844151778282}{}{I}\\ {-}{0.229038486136633}{-}{0.832844151778282}{}{I}\\ {-}{1.15841822127975}{+}{0.302560027651277}{}{I}\\ {-}{1.15841822127975}{-}{0.302560027651277}{}{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.011495783482013959}& {-}{0.0792118813135806}& {0.03789974391987416}\\ {0.4518160658051807}& {0.06381632034386281}& {0.0}& {1.1948501766303492}& {0.19655078442972945}& {0.12933324848710598}\\ {-}{0.3281768137936811}& {-}{0.00978367900149664}& {0.0}& {-}{0.20247841085995966}& {0.7109579022123055}& {-}{0.10613104493072814}\\ {-}{0.7067972102531872}& {-}{0.10848478901621239}& {0.0}& {-}{0.2903901584751042}& {-}{0.2728580541883377}& {0.8005625262543417}\\ {0.0668216265378686}& {0.025422350609808974}& {-}{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.0264039604378602}\\ {0.0}& {0.0}& {-}{0.06381632034386281}& {-}{0.06551692814324316}\\ {0.0}& {0.0}& {0.00978367900149664}& {0.0963473659292315}\\ {0.0}& {0.0}& {0.10848478901621239}& {0.0909526847294459}\\ {0.0}& {1.0}& {-}{0.025422350609808974}& {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.102357348082745}& {-}{0.000270311690400549}\\ {-}{0.0000225872757992744}& {0.0316301696671073}\\ {0.0324778265476551}& {-}{0.0304093686252613}\\ {0.0704309874231960}& {-}{0.0320525534560707}\\ {0.129070756498193}& {-}{0.0489238268986028}\\ {-}{0.175506475656645}& {0.0836901688540360}\end{array}\right]$ (6)
 > $M≔{\mathrm{Kgc}}_{2}$
 ${M}{:=}\left[\begin{array}{cc}{0.0253685913778668}& {0.00580736351020937}\\ {0.0274697247200146}& {0.000676794859878094}\\ {-}{0.0218446273185275}& {0.00178225871544269}\\ {0.0372133592990484}& {-}{0.0820508803834719}\\ {0.00217310991241623}& {-}{0.103403563367287}\\ {-}{0.0216515967775457}& {-}{0.0367013114464034}\end{array}\right]$ (7)
 > $P≔{\mathrm{Kgc}}_{3}$
 ${P}{:=}\left[\begin{array}{cccccc}{1.1900369256596513680607898030612988623584891281402}& {-}{0.0023320086064175048899258969807954270227548522818880}& {0.0061998830727381696056576545154575265911348375845696}& {0.014704192587601949550717991168837844758344731754324}& {-}{0.26910475814297038128402370917552208492796758876793}& {-}{0.17883726257937578550735449514449452405359678084255}\\ {-}{0.0023320086064175048899258969807954270227548522818880}& {0.61670692397661137902111398074559126170661471703263}& {0.062957575284920775588554468643085922035187577653151}& {0.033808441428112021970248795837252732424645784995003}& {0.076819002522201942540467165035476808973156473561517}& {-}{0.15462446647953120435059800592149820764416574032743}\\ {0.0061998830727381696056576545154575265911348375845696}& {0.062957575284920775588554468643085922035187577653151}& {14.025849351583923302511522746740757462854251915280}& {7.4346882006071747986498635379335678012229658353196}& {-}{3.5696824876652967265205292382960357973826279534315}& {-}{11.113108178702450121289037076910207269094101389367}\\ {0.014704192587601949550717991168837844758344731754324}& {0.033808441428112021970248795837252732424645784995003}& {7.4346882006071747986498635379335678012229658353196}& {13.426727737551110049795524207929623441510359391648}& {7.5154614042932047552613742430063947286905270050822}& {-}{3.4406863413257253173229434759258383523934697191380}\\ {-}{0.26910475814297038128402370917552208492796758876793}& {0.076819002522201942540467165035476808973156473561517}& {-}{3.5696824876652967265205292382960357973826279534315}& {7.5154614042932047552613742430063947286905270050822}& {12.866973006797875753555529233728089252760730021805}& {7.6916212029430738467523520483451516520869596367904}\\ {-}{0.17883726257937578550735449514449452405359678084255}& {-}{0.15462446647953120435059800592149820764416574032743}& {-}{11.113108178702450121289037076910207269094101389367}& {-}{3.4406863413257253173229434759258383523934697191380}& {7.6916212029430738467523520483451516520869596367904}& {12.493137962447477563055736963067896564962024699054}\end{array}\right]$ (8)
 > $Z≔{\mathrm{Kgc}}_{4}$
 ${Z}{:=}\left[\begin{array}{cccccc}{1.18188087158660}& {-}{0.00894129363564162}& {0.0105368063732044}& {0.0386074206788732}& {-}{0.228656565417310}& {-}{0.159304648663610}\\ {-}{0.00894129363564162}& {0.609921640861491}& {0.0681998220209577}& {0.0301077503041019}& {0.0831297100291734}& {-}{0.146882484090741}\\ {0.0105368063732044}& {0.0681998220209577}& {14.0214547536995}& {7.44986437971970}& {-}{3.55919925249275}& {-}{11.1137202257129}\\ {0.0386074206788732}& {0.0301077503041019}& {7.44986437971970}& {12.9843151882215}& {6.96975115349677}& {-}{3.62844351133959}\\ {-}{0.228656565417310}& {0.0831297100291734}& {-}{3.55919925249275}& {6.96975115349677}& {12.1763352572658}& {7.44503057189327}\\ {-}{0.159304648663610}& {-}{0.146882484090741}& {-}{11.1137202257129}& {-}{3.62844351133959}& {7.44503057189327}& {12.4006153119887}\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.557923700567850}{+}{0.764621079685664}{}{I}\\ {0.557923700567850}{-}{0.764621079685664}{}{I}\\ {-}{0.329933413511178}{+}{0.}{}{I}\\ {0.313799485979058}{+}{0.}{}{I}\\ {0.178331258878923}{+}{0.146122594413458}{}{I}\\ {0.178331258878923}{-}{0.146122594413458}{}{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.015113993845464488}& {0.954597949208161}& {0.01705955801720272}& {-}{0.02608590583762036}& {0.02362388200129928}& {-}{0.005556769726110113}\\ {0.10525701853472595}& {-}{0.010533351101903584}& {-}{0.000003764545967298646}& {-}{0.008428939605937043}& {0.03035969251606879}& {-}{0.015181226588393075}\\ {0.000819834702993101}& {-}{0.004298133361596655}& {0.0054129710923584515}& {0.9998092759585139}& {-}{0.021614834350949012}& {0.012792173240136883}\\ {-}{0.004498562309139447}& {-}{0.0206184765793089}& {0.011738497906213702}& {-}{0.009451682532862752}& {0.9856634457508713}& {0.011472393021399718}\\ {-}{0.010061625606990619}& {-}{0.041056838344424355}& {0.021511792754001273}& {-}{0.01993839504624442}& {-}{0.016850363967056945}& {1.0163128393237777}\\ {0.01050277993293108}& {0.05010615508734418}& {-}{0.029251079281957637}& {0.35586760983383564}& {-}{1.360608948894866}& {1.5029124117163541}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{cccc}{-}{0.03407406407576061}& {-}{0.0169514333410425}& {0.10235734808274485}& {-}{0.0002703116904005486}\\ {0.9947358341463601}& {-}{0.012648303320875623}& {-}{0.000022587275799274422}& {0.0316301696671073}\\ {-}{0.005757714076245259}& {0.006750776357746068}& {0.032477826547655145}& {-}{0.030409368625261297}\\ {-}{0.018134903561637435}& {0.0010825234762145842}& {0.07043098742319602}& {-}{0.03205255345607071}\\ {-}{0.034869614343697536}& {-}{0.0019422619945601352}& {0.1290707564981935}& {-}{0.04892382689860284}\\ {0.04455379706790229}& {0.9957750117403432}& {-}{0.17550647565664454}& {0.08369016885403602}\end{array}\right]\\ {\mathrm{c}}{=}\left[\begin{array}{cccccc}{0.9951662524794316}& {-}{0.013210717334733373}& {0.004228098563823411}& {-}{0.008031714732491705}& {0.011494406959153766}& {-}{0.0041969006718662735}\\ {-}{0.004194921228383584}& {0.987565635175068}& {0.004578287454251416}& {-}{0.007200519391203347}& {0.0070593255014349526}& {-}{0.0018509573503303035}\\ {0.002906193173491886}& {0.009114637010923823}& {0.9963592287795172}& {0.005107246879710164}& {-}{0.0033861113418508395}& {0.000358106223253505}\\ {0.009681517215471145}& {0.01081102267242556}& {0.006202226551081839}& {1.0123701540551333}& {-}{0.07008572799661841}& {0.03731701372607968}\\ {0.018826865825410717}& {0.03350202783522921}& {0.0003621849854751414}& {0.027018933248821445}& {0.9012396381470698}& {0.04951298207749944}\\ {0.010004183124675577}& {0.021856702382585223}& {-}{0.0036085994636460093}& {0.01532020222726572}& {-}{0.040285298237651715}& {1.0188194959781487}\\ {0.14372028052454733}& {0.4316017487765955}& {-}{0.16209866622662222}& {0.24802219942274498}& {-}{0.22503341322737008}& {0.05308052898232607}\\ {0.17220169434418128}& {0.3079543257861113}& {0.0018831787858143365}& {0.2474933678048904}& {-}{0.8987348208510474}& {0.45005790921993866}\end{array}\right]\\ {\mathrm{d}}{=}\left[\begin{array}{cccc}{-}{0.009424091043671768}& {-}{0.0065510439679071575}& {0.02536859137786675}& {0.0058073635102093655}\\ {-}{0.009269374049091436}& {-}{0.004849005398202654}& {0.027469724720014552}& {0.0006767948598780942}\\ {0.006984499319481142}& {0.0029278677343056543}& {-}{0.02184462731852746}& {0.001782258715442691}\\ {0.001270693634871332}& {0.026618125602306912}& {0.037213359299048364}& {-}{0.08205088038347187}\\ {0.016509557260594956}& {0.04099924036143961}& {0.0021731099124162267}& {-}{0.10340356336728687}\\ {0.013334084167417477}& {0.018289124042207387}& {-}{0.021651596777545738}& {-}{0.03670131144640344}\\ {0.3238666518889224}& {0.16130503310583014}& {0.027408002834784968}& {0.0019840828019802442}\\ {0.15272171036899113}& {0.37368818419384714}& {0.011299072712626205}& {0.061071592550846376}\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.015113993845464488}& {0.954597949208161}& {0.01705955801720272}& {-}{0.02608590583762036}& {0.02362388200129928}& {-}{0.005556769726110113}\\ {0.10525701853472595}& {-}{0.010533351101903584}& {-}{0.000003764545967298646}& {-}{0.008428939605937043}& {0.03035969251606879}& {-}{0.015181226588393075}\\ {0.000819834702993101}& {-}{0.004298133361596655}& {0.0054129710923584515}& {0.9998092759585139}& {-}{0.021614834350949012}& {0.012792173240136883}\\ {-}{0.004498562309139447}& {-}{0.0206184765793089}& {0.011738497906213702}& {-}{0.009451682532862752}& {0.9856634457508713}& {0.011472393021399718}\\ {-}{0.010061625606990619}& {-}{0.041056838344424355}& {0.021511792754001273}& {-}{0.01993839504624442}& {-}{0.016850363967056945}& {1.0163128393237777}\\ {0.01050277993293108}& {0.05010615508734418}& {-}{0.029251079281957637}& {0.35586760983383564}& {-}{1.360608948894866}& {1.5029124117163541}\end{array}\right]\\ {\mathrm{b}}{=}\left[\begin{array}{cccc}{-}{0.03407406407576061}& {-}{0.0169514333410425}& {0.10235734808274485}& {-}{0.0002703116904005486}\\ {0.9947358341463601}& {-}{0.012648303320875623}& {-}{0.000022587275799274422}& {0.0316301696671073}\\ {-}{0.005757714076245259}& {0.006750776357746068}& {0.032477826547655145}& {-}{0.030409368625261297}\\ {-}{0.018134903561637435}& {0.0010825234762145842}& {0.07043098742319602}& {-}{0.03205255345607071}\\ {-}{0.034869614343697536}& {-}{0.0019422619945601352}& {0.1290707564981935}& {-}{0.04892382689860284}\\ {0.04455379706790229}& {0.9957750117403432}& {-}{0.17550647565664454}& {0.08369016885403602}\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.148148148129629620}& {0.4444444443}& {-0.166666666699999994}& {0.255555555561111092}& {-0.233333333379999980}& {0.0555555555511110799}\\ {0.185185185220370363}& {0.3333333334}& {0.}& {0.266666666619999992}& {-0.959999999999999964}& {0.479999999900000085}\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.333333333299999979}& {0.166666666699999994}& {0}& {0}\\ {0.166666666699999994}& {0.400000000000000022}& {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.