mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-19 11:38:05 +02:00
Add kalman filter
This commit is contained in:
parent
362ee691b1
commit
8a46e994b5
4 changed files with 87 additions and 0 deletions
33
tikz/kalman-filter/Makefile
Normal file
33
tikz/kalman-filter/Makefile
Normal file
|
@ -0,0 +1,33 @@
|
|||
SOURCE = kalman-filter
|
||||
DELAY = 80
|
||||
DENSITY = 300
|
||||
WIDTH = 512
|
||||
|
||||
make:
|
||||
pdflatex $(SOURCE).tex -output-format=pdf
|
||||
make clean
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot
|
||||
|
||||
gif:
|
||||
pdfcrop $(SOURCE).pdf
|
||||
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
|
||||
make clean
|
||||
|
||||
png:
|
||||
make
|
||||
make svg
|
||||
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
|
||||
|
||||
transparentGif:
|
||||
convert $(SOURCE).pdf -transparent white result.gif
|
||||
make clean
|
||||
|
||||
svg:
|
||||
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
|
||||
pdf2svg $(SOURCE).pdf $(SOURCE).svg
|
||||
# Necessary, as pdf2svg does not always create valid svgs:
|
||||
inkscape $(SOURCE).svg --export-width=$(WIDTH) --export-plain-svg=$(SOURCE)1.svg
|
||||
rsvg-convert -a -w 720 -f svg $(SOURCE)1.svg -o $(SOURCE).svg
|
||||
rm $(SOURCE)1.svg
|
5
tikz/kalman-filter/README.md
Normal file
5
tikz/kalman-filter/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
Compiled example
|
||||
----------------
|
||||

|
||||
|
||||
Example for a block-diagram.
|
BIN
tikz/kalman-filter/kalman-filter.png
Normal file
BIN
tikz/kalman-filter/kalman-filter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
49
tikz/kalman-filter/kalman-filter.tex
Normal file
49
tikz/kalman-filter/kalman-filter.tex
Normal file
|
@ -0,0 +1,49 @@
|
|||
\documentclass[varwidth=true, border=2pt]{standalone}
|
||||
|
||||
\usepackage{pgfplots}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{shapes,arrows,arrows.meta}
|
||||
\pgfplotsset{compat=1.13}
|
||||
\usepackage{mathtools}
|
||||
\usepackage{amssymb}
|
||||
|
||||
\begin{document}
|
||||
\tikzstyle{block} = [draw, rectangle, minimum width=6em, align=center,fill=gray!5]
|
||||
\tikzstyle{arrow} = [-latex, very thick]
|
||||
\newcommand*{\tran}{\top}
|
||||
|
||||
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
|
||||
\setlength{\abovedisplayskip}{0pt}
|
||||
|
||||
% Place the blocks
|
||||
\node[text width=1cm,
|
||||
rounded corners=3pt,
|
||||
block,
|
||||
label={[above,align=center]{Initial\\State}}] at (-1, 0) (initial)
|
||||
{$$\mathbf{x}_0$$ $$P_0$$};
|
||||
\node at (0.25, 0.1) (sum) {};
|
||||
\node[block, text width=6cm,
|
||||
label={[above,align=center]{Prediction}}] at (4, 0) (prediction)
|
||||
{\begin{align*}
|
||||
\mathbf{x}_{k+1}^{(P)} &= A x_k + B {\color{orange} a_k}\\
|
||||
P_{k+1}^{(P)} &= A P_k A^\tran + C_k^{(r_s)}
|
||||
\end{align*}};
|
||||
\node [block, right of=prediction,
|
||||
node distance=3cm, text width=1.4cm] at (6, -2) (iterUpdate)
|
||||
{$$k \leftarrow k + 1$$};
|
||||
\node [block, text width=6cm,
|
||||
label={[above,align=center]{Innovation}}] at (4, -4) (innovation)
|
||||
{\begin{align*}
|
||||
K_k &= P_k^{(P)} H^\tran {\left (H P_k^{(P)} H^\tran + C_k^{(r_m)} \right)}^{-1}\\
|
||||
{\color{blue} \mathbf{x}_k} &= \mathbf{x}_k^{(P)} + K_k \left ({\color{orange} z_k} - H \mathbf{x}_k^{(P)} \right )\\
|
||||
{\color{blue} P_k} &= (I - K_k H) P_k^{(P)}
|
||||
\end{align*}};
|
||||
|
||||
% Connect the nodes
|
||||
\draw [arrow] (initial) -- (prediction);
|
||||
\draw [arrow] (prediction.east) -| (iterUpdate.north);
|
||||
\draw [arrow] (iterUpdate) |- (innovation);
|
||||
\draw [arrow] (innovation.west) -| (sum);
|
||||
\end{tikzpicture}
|
||||
|
||||
\end{document}
|
Loading…
Add table
Add a link
Reference in a new issue