The Mathematica built-in symbol
EstimatorRegulator
can assemble an estimator-regulator type compensator in a variety of combinations. In this case, we use an optimal regulator for the controller design and an optimal estimator (also known as a Kalman Estimator) to control an unstable, discrete-time state space model with two states:
In[]:=
ssm=StateSpaceModel[{{{0.,-1.},{-0.5,1}},{{1},{2}},{{1,0}},{{0}}}]
Out[]=
0.
-1.
1
-0.5
1
2
1
0
0
There is a positive eigenvalue which makes the system unstable:
In[]:=
Eigenvalues[First[Normal[ssm]]]
Out[]=
{1.36603,-0.366025}
The gains of the optimal estimator can be directly obtained using
LQEstimatorGains
, while the optimal regulator controller gains are obtained using
LQRegulatorGains
:
In[]:=
{ℓ,κ}=LQEstimatorGains[{ssm,1,1},{w={{}},v=(
0.1
)}],LQRegulatorGainsssm,q=
4
10
0
0
2
10
,r=(
2
10
)
Out[]=
{{{2.73205},{-3.73205}},{{-12.3562,13.1205}}}
The estimator-regulator is assembled using the computed optimal estimator and controller gains:
In[]:=
cdER=EstimatorRegulator[ssm,{ℓ,κ},"Data"];​​cdER["Design"]
Out[]=
estimator and regulator
The combination of an Kalman estimator and optimal regulator controller in fact constitutes a special type of regulator, called a linear quadratic gaussian (LQG) regulator, which has it’s own built-in symbol in Mathematica,
LQGRegulator
. It can construct the regulator directly from the covariance matrices {
w
,
v
} and weights {
q
,
r}
:
In[]:=
cdLQG=LQGRegulator[{ssm,1,1},{w,v},{q,r},"Data"];​​cdLQG["Design"]
Out[]=
linear quadratic gaussian regulator
From their respective data controller data objects, we can extract information about each system’s properties as shown below. As expected, the resulting controllers are identical, with both closed-loop systems having the same eigenvalues:
In[]:=
RowDatasetTable{props,EstimatorRegulator[ssm,{ℓ,κ},props]},props,
props
,DatasetTable{props,LQGRegulator[{ssm,1,1},{w,v},{q,r},props]},props,
props

Out[]=
Design
estimator and regulator
ClosedLoopSystem
…
ClosedLoopPoles
{-9.83292,-3.05182,-1.36603,-0.366025}
EstimatorRegulatorModel
-2.73205
-1.
1.
2.73205
3.23205
1.
2.
-3.73205
-12.3562
13.1205
0.
0.
Design
linear quadratic gaussian regulator
ClosedLoopSystem
…
ClosedLoopPoles
{-9.83292,-3.05182,-1.36603,-0.366025}
EstimatorRegulatorModel
-2.73205
-1.
1.
2.73205
3.23205
1.
2.
-3.73205
-12.3562
13.1205
0.
0.