我想在另一个块内绘制一个块,如下图所示
如果图片不清楚,我深感抱歉。我的问题是如何在另一个块内绘制一个块?图片的其余部分我没有问题。
答案1
这是绘制图表的一种方法。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows}
\begin{document}
\begin{center}
\begin{tikzpicture}[auto,node distance=2cm,>=stealth']
\tikzset{block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle, node distance=2cm},
input/.style = {coordinate},
output/.style = {coordinate}}
\node [input, name=rinput](rinput) {};
\node [sum, right of=rinput] (sum) {$\sum$};
\node [block, right of=sum] (controller) {};
\node [block, right of=controller,node distance=3cm] (system) {};
\node[block, right of =system, node distance=4cm] (output){Output};
\node[above of = output] (A) {};
\node[fit= (A) (output), dashed,draw,inner sep=0.45cm] (Box){Some text};
\draw [->] (controller) -- node[name=u] {}(system);
\node [coordinate, below of=u] (measurements) {};
\draw [->] (rinput) -- node {} (sum);
\draw [->] (sum) -- node {} (controller);
\draw [->] (system) -- ( system -| Box.west);
\draw [-] (output.south) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$}
node [near end] {} (sum);
\end{tikzpicture}
\end{center}
\end{document}
更新:由于OP有后续内容,因此添加了附录。 这里在输出的右侧添加了一个新节点(B),以便可以绘制箭头连接(B)。
\begin{document}
\begin{center}
\begin{tikzpicture}[auto,node distance=2cm,>=stealth']
\tikzset{block/.style= {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle}}
\node [coordinate] (rinput) {};
\node [sum, right of=rinput] (sum) {$\sum$};
\node [block, right of=sum] (controller) {C};
\node [block, right of=controller] (system) {SYS};
\node [block, right of =system, node distance=3cm] (output) {Output};
\node (A) [above =0.3cm of output] {Some text here};
\node[fit= (A) (output), dashed,draw,inner sep=0.2cm] (Box) {};
\node [coordinate, right = 2cm of output] (B) {}; %%% newly added
\draw [->] (controller) -- node[name=u] (system) {};
\node [coordinate, below=1.5cm of u] (measurements) {};
\draw [->] (rinput) -- (sum);
\draw [->] (sum) -- (controller);
\draw [->] (system) -- (system -| Box.west);
\draw [->] (Box.east |- B) -- (B); %%% newly added
\draw [-] (output.south) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$} node [near end] {} (sum);
\end{tikzpicture}
\end{center}
\end{document}
答案2
只是对 Jesse 代码做了一些小的修改/简化:
\documentclass[tikz,border=5mm]{standalone}% my modification
\usetikzlibrary{arrows,fit,positioning}
\begin{document}
\begin{tikzpicture}[node distance=2cm, >=stealth',
block/.style = {draw, rectangle, minimum height=2em,minimum width=4em},
sum/.style = {draw, circle},
]
\coordinate (rinput);
\node[sum, right = of rinput] (sum) {$\sum$};
\node[block, right = of sum] (controller) {control};
\node[block, right = 3cm of controller](system) {system};
\node[block, right = 4cm of system] (output) {Output};
\node[above = of output] (A) {};
\node[fit= (A) (output),
dashed, draw, inner sep=0.45cm] (Box) {Some text};
\draw [->] (controller) -- (system);
\draw [->] (rinput) -- (sum);
\draw [->] (sum) -- (controller);
\draw [->] (system) -- (system -| Box.west);
\coordinate[below = of sum] (measurements);
\draw [->] (output.south) |- (measurements) -- (sum.south) node[below left] {$-$};
\end{tikzpicture}
\end{document}