% The block diagram code is probably more verbose than necessary \begin{tikzpicture}[auto, node distance=2cm,>=latex'] % We start by placing the blocks \node [input, name=input] {}; \node [sum, right of=input] (sum) {}; \node [block, right of=sum] (controller) {Controller}; \node [block, right of=controller, pin={[pinstyle]above:Disturbances}, node distance=3cm] (system) {System}; % We draw an edge between the controller and system block to % calculate the coordinate u. We need it to place the measurement block. \draw [->] (controller) -- node[name=u] {$u$} (system); \node [output, right of=system] (output) {}; \node [block, below of=u] (measurements) {Measurements};
% Once the nodes are placed, connecting them is easy. \draw [->] (input) -- node {$r$} (sum); \draw [->] (sum) -- node {$e$} (controller); \draw [->] (system) -- node [name=y] {$y$}(output); \draw [->] (y) |- (measurements); \draw [->] (measurements) -| node[pos=0.99] {$-$} node [near end] {$y_m$} (sum); \end{tikzpicture}
\end{document}
以上代码会带来以下的渲染结果:
我们来分段介绍内容
节点node
节点可以看作骨架,应当是最为基础的部分
node有三种定义方式:
使用\node定义,这里的定义方式应当为\node [style and place] (name) {label}
在draw中定义,这种定义往往是用于在线上写字-- node [name and position] {label}