我喜欢绘制下面的图表:
到目前为止我成功绘制了以下内容:
\begin{tikzpicture}[
block/.style={draw, minimum width=10mm, minimum height=6mm},
sum/.style={circle, draw, minimum size=6mm, inner sep=0pt,
node contents={\huge$+$}},
mult/.style={circle, draw, minimum size=6mm, inner sep=0pt,
node contents={\huge$\times$}},
>=Stealth,
node distance=12mm and 10mm]
\node (b1) [block] {$E$};
\node (b2) [block,below=of b1] {$E$};
\node (b3) [block,below=of b2] {$E$};
\node (b4) [block,below=of b3] {$E$};
\coordinate[left=of $(b1.west)!1.5!(b2.west)$] (in);
\coordinate[left=of $(b1.east)!1.5!(b2.east)$] (out);
\node (m) [mult, right=of b2];
\node (m1) [mult, left=of b2];
\node (s) [sum,right=of out -| m.west];
\node (b5) [block,right=of s] {$h_5[n]$};
%
\draw[<-] (in) -- node[above] {$x[n]$} + (-12mm,0);
\draw[<->] (m1.west)-| (in) |- (b3.west);
\draw[<->] (b1.west) -| (in) |- (b4.west);
\draw[->] (b1) -| (s);
\draw[->] (b2) -- (m);
\draw[->] (m1) -- (b2);
\draw[->] (m) -| (s);
\draw[->] (s) -- (b5);
\draw[->] (b5.east) -- node[above] {$y[n]$} + (12mm,0);
\end{tikzpicture}
这远不是我想要的。在上面的图片中我标记了:
- 带有蓝色标记线,应该更长一些 [这样我就可以把乘法红色块放在那里]
- 我想让 h_5[n] 更大
- 我想定义一个变量(例如 xx)使其进入任何乘法块。
- 另外我怎样才能在第三行和第四行之间垂直放置一个点
答案1
代码不是很简单,但是,它(在我看来)结构良好,描述了每个部分的任务。
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, quotes, positioning}
\usepackage{amssymb}
\begin{document}
\begin{tikzpicture}[
> = Stealth,
node distance = 10mm and 13mm,
start chain = S going below,
block/.style = {draw, minimum size=6mm, inner sep=1mm},
sum/.style = {circle, draw, minimum size=6mm, inner sep=0pt, outer sep=0pt,
font=\huge, node contents={$+$}},
mult/.style = {circle, draw, minimum size=6mm, inner sep=0pt,
font=\huge, node contents={$\times$}},
VD/.style = {minimum height=6mm, node contents={},
yshift=7mm,% <-- for adjustin of vertical distance
% between sum and vertical dots
path picture={\draw[ultra thick, dotted]
(path picture bounding box.north) --
(path picture bounding box.south);}
},
]
% first column: nodes sum
\begin{scope}[every node/.append style={on chain=S}]
\node[sum]; % name: S-1
\node[sum];
\node[VD];
\node[sum];
\node[VD] {};
\node[sum]; % S-6
\end{scope}
% arrows with weights N_1 ... N_N
\draw[<-] (S-1.north) -- + (0,0.3) node[above] {$N_1$};
\draw[<-] (S-2.north) -- + (0,0.3) node[above] {$N_2$};
\draw[<-] (S-4.north) -- + (0,0.3) node[above] {$N_M$};
\draw[<-] (S-6.north) -- + (0,0.3) node[above] {$N_1$};
% second column: nodes E
\begin{scope}[every node/.style={block, node contents={E}}]
\node (E1) [right=of S-1];
\node (E2) [right=of S-2];
\node (E4) [right=of S-4];
\node (E6) [right=of S-6];
\end{scope}
% nodes with vertical dots in second column
\node[VD, below=of E2];
\node[VD, below=of E4];
% arrows with sums x_i[n], drawn as edges with labels
\draw[->] (S-1) edge ["{$x_1[n]$}"] (E1)
(S-2) edge ["{$x_2[n]$}"] (E2)
(S-4) edge ["{$x_N[n]$}"] (E4)
(S-6) edge ["{$x_M[n]$}"] (E6);
% third column: block for wireless sensor network,
% first is measured distance between E1.nort and E6.south
% and than this distance is used as minimal height of block
% here is used library calc
\path let \p1 = ($(E1.north) - (E6.south)$),
\n1 = {veclen(\y1,\x1)} in
node (WSN) [block,
inner ysep=0pt, minimum height=\n1, align=center,
below right = 0mm and 10mm of E1.north east]
{Wireless\\ Sensor\\ Network};
% arrows with weights Y_1 ... Y_N drawn as edges with labels
\draw[->] (E1) edge ["{$Y_1[n]$}"] (E1 -| WSN.west)
(E2) edge ["{$Y_2[n]$}"] (E2 -| WSN.west)
(E4) edge ["{$Y_N[n]$}"] (E4 -| WSN.west)
(E6) to ["{$Y_M[n]$}"] (E6 -| WSN.west);
% fourth column: nodes D
\begin{scope}[every node/.style={block, node contents={D}}]
\node (D1) [right=of E1 -| WSN.east];
\node (D2) [right=of E2 -| WSN.east];
\node (D4) [right=of E4 -| WSN.east];
\node (D6) [right=of E6 -| WSN.east];
\end{scope}
% arrows to nodes D
\draw[->] (D1 -| WSN.east) edge (D1)
(D2 -| WSN.east) edge (D2)
(D4 -| WSN.east) edge (D4)
(D6 -| WSN.east) to (D6);
% nodes with vertical dots in fourth column
\node[VD, below=of D2];
\node[VD, below=of D4];
% auxiliary coordinates used for draw edges from nodes D
\coordinate[right=of D1] (Z1);
\coordinate[right=of D2] (Z2);
\coordinate[right=of D4] (Z4);
\coordinate[right=of D6] (Z6);
% summations of Z_i, node sum is in line with D_4
\node (out) [sum, right=of Z4];
% arrow from nodes D with labels Z_i[n]
\draw[->] (D1) to ["{$Z_1[n]$}"] (Z1) -- (out);
\draw[->] (D2) to ["{$Z_2[n]$}"] (Z2) -- (out);
\draw[->] (D4) to ["{$Z_N[n]$}"] (Z4) -- (out);
\draw[->] (D6) to ["{$Z_M[n]$}"] (Z6) -- (out);
\draw[->] (out) -- + (1,0) node[right] {$\boldmath{\widehat{S}}$};% <-- output
% on the end lets make input to this graph
\coordinate[left=of S-1.west] (X1);
\coordinate[left=of S-2.west] (X2);
\coordinate[left=of S-4.west] (X4);
\coordinate[left=of S-6.west] (X6);
% input x[n]
\coordinate[left=of X4.west] (in);
% input arrows
\draw (in) -- + (-1,0) node[left] {$x[n]$};
\draw[->] (in) -- (X1) -- (S-1);
\draw[->] (in) -- (X2) -- (S-2);
\draw[->] (in) -- (X4) -- (S-4);
\draw[->] (in) -- (X6) -- (S-6);
\end{tikzpicture}
\end{document}
答案2
对于初学者来说,Tikz 无疑是复杂的,因此我建议使用所见即所得的编辑器,例如:GeoGebra/TikzEdt(如果你没有太多时间)。
GeoGebra:https://www.sharelatex.com/blog/2013/08/28/tikz-series-pt2.html
TikzEdt:http://www.tikzedt.org/
但是,请考虑学习编写 Tikz 代码(因为上述程序生成的 Tikz 代码的质量不是很好)。