# State-space model

> The block diagram of x' = Ax + Bu, y = Cx + Du, with the feedback and feedthrough paths. A Block diagrams example with its LaTeX source.

A Block diagrams example in the TeXeR TikZ library: https://texer.org/library/block-diagrams/state-space

Package: [Block diagrams](https://texer.org/library/block-diagrams.md), on CTAN at https://ctan.org/pkg/pgf.

Tags: state space, control systems, linear systems

## Source

```latex
\usetikzlibrary{arrows.meta}

\begin{tikzpicture}[
  block/.style={draw, thick, minimum size=9mm},
  sum/.style={draw, thick, circle, inner sep=0pt, minimum size=5mm},
  arrow/.style={-{Stealth}, thick},
]
  \node[block] (B) at (1.6,0) {$B$};
  \node[sum] (s1) at (3,0) {};
  \node[block] (int) at (4.4,0) {$\int$};
  \node[block] (C) at (6.6,0) {$C$};
  \node[sum] (s2) at (8,0) {};
  \node[block] (A) at (4.4,-1.6) {$A$};
  \node[block] (D) at (4.4,1.6) {$D$};

  \draw[thick] (0,0) node[left] {$u$} -- (0.6,0);
  \draw[arrow] (0.6,0) -- (B);
  \draw[arrow] (B) -- (s1);
  \draw[arrow] (s1) -- node[above] {$\dot{x}$} (int);
  \draw[arrow] (int) -- node[above] {$x$} (C);
  \draw[arrow] (C) -- (s2);
  \draw[arrow] (s2) -- (9.2,0) node[right] {$y$};
  \draw[arrow] (5.6,0) |- (A);
  \draw[arrow] (A) -| (s1);
  \draw[arrow] (0.6,0) |- (D);
  \draw[arrow] (D) -| (s2);
  \fill (0.6,0) circle (1.5pt) (5.6,0) circle (1.5pt);
\end{tikzpicture}
```

## As a complete document

The same example in a document that compiles on its own with pdfLaTeX:

```latex
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}[
  block/.style={draw, thick, minimum size=9mm},
  sum/.style={draw, thick, circle, inner sep=0pt, minimum size=5mm},
  arrow/.style={-{Stealth}, thick},
]
  \node[block] (B) at (1.6,0) {$B$};
  \node[sum] (s1) at (3,0) {};
  \node[block] (int) at (4.4,0) {$\int$};
  \node[block] (C) at (6.6,0) {$C$};
  \node[sum] (s2) at (8,0) {};
  \node[block] (A) at (4.4,-1.6) {$A$};
  \node[block] (D) at (4.4,1.6) {$D$};

  \draw[thick] (0,0) node[left] {$u$} -- (0.6,0);
  \draw[arrow] (0.6,0) -- (B);
  \draw[arrow] (B) -- (s1);
  \draw[arrow] (s1) -- node[above] {$\dot{x}$} (int);
  \draw[arrow] (int) -- node[above] {$x$} (C);
  \draw[arrow] (C) -- (s2);
  \draw[arrow] (s2) -- (9.2,0) node[right] {$y$};
  \draw[arrow] (5.6,0) |- (A);
  \draw[arrow] (A) -| (s1);
  \draw[arrow] (0.6,0) |- (D);
  \draw[arrow] (D) -| (s2);
  \fill (0.6,0) circle (1.5pt) (5.6,0) circle (1.5pt);
\end{tikzpicture}
\end{document}
```
