我是一名初学者,我从这段代码开始
\begin{figure}
\centering
\tikzstyle{block} = [draw, fill=white, rectangle,
minimum height=3em, minimum width=6em]
\tikzstyle{sum} = [draw, fill=white, circle, node distance=1cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
\begin{tikzpicture}[auto, node distance=2cm,>=latex']
\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:D},
node distance=3cm] (system) {System};
\draw [->] (controller) -- node[name=u] {$u$} (system);
\node [output, right of=system] (output) {};
\node [block, below of=u] (measurements) {Measurements};
\draw [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}
\caption{Caption}
\label{fig:my_label}
\end{figure}
结果是
请帮帮我。我需要理解这个多 sumer 框图。非常感谢您的帮助!
答案1
我喜欢使用Tikz编辑为了在 TikZ 中快速绘制我的图表,我的风格集中于先前定义节点,scope
然后再用另一种方式scope
定义所有连接。
作为一名控制工程师,我已经用 创建了自己的样式,tikzset
并尽可能多地重复使用它们。所以请不要为我的自定义样式而烦恼:addCross
、mySimpleArrow
和myBlockOpacity
。我能给出的主要建议是创建灵活的命令(带参数)并定义默认样式。这比基本用法有了很大的改进。
请注意,我没有将标签移到您示例所显示的确切位置;我使用了我的addCross
,您可以将其更改为在其他位置显示符号,或者只使用圆圈并手动移位符号。我也没有更改任何字体,因为我不知道您想使用哪种字体。您可以检查字体这里。
为了给出一些参数如何相互作用的一个很好的例子,我在代码中使用了颜色red
和。只需根据需要更改它们即可。purple
minimum height
命令和 也同样如此minimum width
。更改它们以更好地适合您的文档。
为了并排开始和结束箭头,我使用[yshift=<measure>]
了这个答案。
編輯註釋:我已更正e_2
到块u_0
后面Non-linear
。复制图表时犯了错误。
MWE 如下:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{addCross/.style n args={6}{
minimum size={#5 mm}, %minimum height=10mm,
path picture={
\draw[#6]
(path picture bounding box.south east) -- (path picture bounding box.north west)
(path picture bounding box.south west) -- (path picture bounding box.north east);
\node at ($(path picture bounding box.south)!0.4!(path picture bounding box.center)$) {#1};
\node at ($(path picture bounding box.west)!0.4!(path picture bounding box.center)$) {#2};
\node at ($(path picture bounding box.north)!0.4!(path picture bounding box.center)$) {#3};
\node at ($(path picture bounding box.east)!0.4!(path picture bounding box.center)$) {#4};
}
},
addCross/.default={}{}{}{}{10}{}
}
\tikzset{mySimpleArrow/.style n args={2}{
>={latex[#1]},
every path/.style={draw=#2}
},
mySimpleArrow/.default={black}{black}
}
\tikzset{myBlockOpacity/.style n args={2}{
every node/.style={rectangle,draw,
minimum width=1cm, minimum height=1cm,
text=black,
fill opacity=#1, text opacity=#2}
},
myBlockOpacity/.default={0.4}{1}
}
\begin{document}
\begin{tikzpicture}[very thick]
\begin{scope}[blue]
\node[circle,draw,addCross={$-$}{$+$}{}{}{10}{red}] (S1) at (-2,2) {};
\node[circle,draw,addCross={$-$}{$+$}{}{}{10}{blue}] (S2) at (-0.5,1) {};
\node[circle,draw,addCross={$-$}{$+$}{}{}{10}{purple}] (S3) at (5.5,1.5) {};
\end{scope}
\begin{scope}[myBlockOpacity, rounded corners, align=center]
\node[fill=orange, minimum height=80pt, minimum width=60pt] (T) at (-5.5,1.5)
{Transient \\Profile \\Generator};
\node[fill=blue] (P) at (10.5,1.5) {Plant};
\node[fill=green, minimum height=80pt] (N) at (2.5,1.5)
{Non-linear \\ State Error \\Feedback};
\node[fill=yellow, minimum height=80pt] (E) at (7,-2)
{Extended \\ State \\Observer};
\end{scope}
\begin{scope}[blue,mySimpleArrow={blue}{blue}]
\path[->] (-7.5,1.5) node[above]{$r$} -- (T);
\path[->] ([yshift=5mm] T.east) -- (S1) node[above, midway]{$r_1$};
\path[->] ([yshift=-5mm] T.east) -- (S2) node[above, midway]{$r_2$};
\path[->] (S1) -- ([yshift=5mm] N.west) node[midway, above] {$e_1$};
\path[->] (S2) -- ([yshift=-5mm] N.west) node[midway, above] {$e_2$};
\path[->] (N) -- (S3) node[midway, below] {$u_0$};
\path[->] (S3) -- ++(3,0) coordinate(u) -- (P);
\path[->] (u) |- ([yshift=10pt]E.east) node[above right, midway]{$u$};
\path[->] (P) -- ++(1,0) coordinate(y) |- ([yshift=-10pt]E.east);
\path[->] (y) -- ++(1,0) node[above]{$y$};
\path[->,red] ([yshift=-20pt] E.west) -| (S1) node[above right, midway]{$z_1$};
\path[->] (E) -| (S2) node[above right, midway]{$z_2$};
\path[->,purple] ([yshift=20pt] E.west) -| (S3) node[above right, midway]{$z_3$};
\end{scope}
\end{tikzpicture}
\end{document}