New in Wolfram
Mathematica
8: Integrated Control Systems Design
◄
previous
|
next
►
Application Areas
Construct a Kalman Filter for a Stochastic System
Output of a system before and after optimal filtering.
In[2]:=
X
antenna = \!\(\* TagBox[ SubsuperscriptBox[ FormBox[ TagBox[ RowBox[{"(", "", GridBox[{ {"0.5", "0.07869", "0.0042", "0.0104"}, {"0", RowBox[{"-", "0.60653"}], "0.0786", "0.00786"}, {"1", "0", "0", "0"} }, AllowScriptLevelChange->False, BaseStyle->(Deployed -> False), GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxDividers->{ "Columns" -> {False, False, True, {False}, False}, "ColumnsIndexed" -> {}, "Rows" -> {False, False, True, {False}, False}, "RowsIndexed" -> {}}, GridBoxItemStyle->{ "ItemsIndexed" -> {{{1, 1}, {}} -> { Deployed -> True, ShowStringCharacters -> False}, {{}, {1, 1}} -> { Deployed -> True, ShowStringCharacters -> False}}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}}], "", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]], StandardForm], FormBox["0.1", StandardForm], FormBox[ StyleBox["\<\"\[ScriptCapitalS]\"\>", Editable->False, ShowStringCharacters->False, "NodeID" -> 64], StandardForm], MultilineFunction->None], {StateSpaceModel, { SamplingPeriod -> 0.1, Control`CommonDump`noD -> True}}]\); W = {{0.01}}; V = {{0.001}}; kalmanFilter = SystemsModelExtract[KalmanEstimator[{antenna, All, 1}, {W, V}], All, {3}]; u = Table[Sin[(2 \[Pi] i)/20.0], {i, 100}]; processNoise = RandomReal[NormalDistribution[0, Sqrt[W[[1, 1]]]], {100}]; measurementNoise = RandomReal[NormalDistribution[0, Sqrt[V[[1, 1]]]], {100}]; y = Flatten[OutputResponse[antenna, {u, processNoise}]] + measurementNoise; ListLinePlot[y] ListLinePlot[OutputResponse[kalmanFilter, {u, y}]]
Out[1]=
Out[2]=
Out[2]=