Skip to content
Snippets Groups Projects
Commit 4bb54056 authored by Sebastian Schwarz's avatar Sebastian Schwarz
Browse files

fix V10_kalmanfilter_demonstration.ipynb

parent 4ea9d9fc
No related branches found
No related tags found
No related merge requests found
......@@ -2,5 +2,5 @@ scilab-kernel==0.9.10
numpy==1.19.5
scipy==1.6.1
control==0.9.2
matplotlib==3.6.0
matplotlib==3.6.1
PyGnuplot==0.12.3
......@@ -163,6 +163,11 @@
}
],
"source": [
"%matplotlib inline\n",
"from ipywidgets import interactive\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"tini = 0 # Start time\n",
"tfinal = 6 # End time\n",
"dt = 0.01 # Time Step\n",
......@@ -170,18 +175,12 @@
"Ts = 0.1 # Sampling time for discrete time\n",
"\n",
"\n",
"%matplotlib widget\n",
"def update(sigma = 0.2, u=\"off\", xo=3, Q=1e-9, R=0.2, Pk=1):\n",
" fig = plt.figure()\n",
" ax = fig.add_subplot(1, 1, 1)\n",
" fig.set_dpi(120)\n",
" ax.grid(True)\n",
" \n",
"@widgets.interact(sigma=(0.1, 2, 0.1), u = [\"on\",\"off\"], xo=(-10, 10, 1),\n",
" Q=[1, 0.1, 0.01, 0.001, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8, 1e-9, 1e-10],\n",
" R=(0.01, 1, 0.01), Pk=(0.01, 10, 0.01))\n",
"\n",
"def update(sigma = 0.2, u=\"off\", xo=3, Q=1e-9, R=0.2, Pk=1):\n",
" \"\"\"Remove old lines from plot and plot new one\"\"\"\n",
" [l.remove() for l in ax.lines]\n",
" [l.remove() for l in ax.lines]\n",
" \n",
......@@ -213,7 +212,11 @@
"\n",
" ax.plot(out[0,:],out[3,:],'lightblue',out[0,:],out[2,:],'blue',out[0,:],out[4,:],'green')\n",
" ax.legend(['Sensor','System','Ausgabe Kalman-Filter'])\n",
" plt.show()"
" plt.show()\n",
"\n",
"\n",
"interactive_plot = interactive(update, sigma=(0.1, 2, 0.1), u = ["on","off"], xo=(-10, 10, 1), Q=[1, 0.1, 0.01, 0.001, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8, 1e-9, 1e-10], R=(0.01, 1, 0.01), Pk=(0.01, 10, 0.01))\n",
"interactive_plot"
]
},
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment