复杂的 TikZ 图

复杂的 TikZ 图

我目前正在完成我的学士论文,并使用 Latex 和 TikZ。尽管我提出了一些 TikZ 问题,这些问题确实有助于我的理解,但我还是被这个问题难住了。

在此处输入图片描述

我甚至无法画出漂亮的矩形,我不知道是不是因为我对 tikz 完全陌生,或者是我已经两个多星期没有使用 tikz 了,或者两者兼而有之。

如能得到帮助将非常感激!

这是我的可怜代码,它甚至无法编译:(

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows, positioning, quotes}
\usetikzlibrary{arrows.meta, positioning, decorations.markings}

\begin{document}

\begin{tikzpicture}

        % Block Definition
        [block/.style={draw,minimum width=#1,minimum height=2em},
         block/.default=10em,high/.style={minimum height=3em},auto,
          node distance=10mm, % initially 1cm
          >=Stealth]
         %node distance=5em,auto]

        % Nodes
        \node (n0) {Input u};
        \node[block, high, right=2cm of n0] (n1) {System};
        \node[block, high, below = of n1] (n2) {Model};
        \node (n3) {Input Z}
        \node (n4) {Summation}
        \node (n5) {Intersection}

        % Connections
        \draw[->] (n0) -- (n1);


    \end{tikzpicture}

\end{document}

答案1

这是你可以开始的东西。有更简单的方法可以做到这一点,但对于初学者,我喜欢像在这个例子中那样把事情说清楚。我没有添加任何解释,这是我给你的练习,我也省略了很多文字,从代码中的几个例子中应该可以明显看出如何添加这些文字

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows, positioning, quotes}
\usetikzlibrary{arrows.meta, positioning, decorations.markings}

\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
  [
  block/.style={draw,minimum width=#1,minimum height=2em},
  block/.default=10em,high/.style={minimum height=3em},auto,
  node distance=10mm, % initially 1cm
  >=Stealth]

  \node[block, high,] (n1) at (0,0) {System};
        \node[block, high, below =2cm of n1] (n2) {Model};

        \coordinate (a) at ($(n1.west)+(-2,0)$);


        \draw[->] (a) -- (n1)
        coordinate[pos=0.4] (b) 
        ;

        \fill (b) circle (2pt);

        \draw[->] (b) |- ($(n2.north west)!2/3!(n2.south west)$);


        \coordinate (c1) at ($(n1.east)+(1,0)$);

        \node[draw,circle, minimum width=4mm, inner sep=0pt] (C1) at (c1) {};


        \draw[->] (n1) -- (C1);

        \coordinate (d) at ($(C1.east)+(3.5,0)$);

        \draw[->] (C1) -- (d)
        coordinate[pos=0.3] (e) 
        coordinate[pos=0.6] (f) 
        ;

        \fill (e) circle (2pt);
        \fill (f) circle (2pt);

        \coordinate (g) at ($(C1.north)+(0,1)$);

        \draw[->] (g) -- (C1)
        node[pos=0.2,right] {$Z\dots$}
        ;


        \coordinate (c2) at ($(f)+(0,-1.5em-1cm)$);

        \node[draw,circle, minimum width=4mm, inner sep=0pt] (C2) at (c2) {};


        \draw[->] (f) -- (C2);
        \draw[->] (C2) -- ++(1.5,0)
        node[right] {$e\dots$};

        \draw[->]
        (e) -- (e |- C2)
        -- (n2.north west |- C2)
        -- ++(-0.5,0)
        |-
        ($(n2.north west)!1/3!(n2.south west)$);
        ;


        \coordinate (g) at (d |- n2.east);

        \draw[->] (n2) -- (g);

        \coordinate (h) at (C2.center |- g);


        \fill (h) circle (2pt);

        \draw[->] (h) -- (C2);


    \end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

在此处输入图片描述

使用相对坐标,为 和box节点定义样式:dotsum

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, 
                calc,
                positioning, 
                quotes,
                decorations.markings}

\begin{document}
    \begin{tikzpicture}[auto,
     node distance = 12mm and 9mm,
        box/.style = {draw, minimum width=22mm, minimum height=7mm},
        dot/.style = {circle, fill, minimum size=4pt, inner sep=0pt, outer sep=0pt,
                      node contents={}  },
        sum/.style = {circle, draw, minimum size=8pt, inner sep=0pt, outer sep= 0pt,
                      node contents={}},
                > = Stealth,
every edge/.style = {draw, ->}
                    ]
 % Nodes
\coordinate (in);
\node (n1) [dot, right=of in];
\node (n2) [box, right=of n1]   {System};
\node (n3) [sum, right=of n2];
\node (n4) [dot, right=of n3];
\node (n5) [dot, right=of n4];
\coordinate[right=of n5] (out1);
%
\node (n6) [box, below=of n2]   {Model};
\node (n7) [dot, at={(n6 -| n5)}];
\coordinate[right=of n7] (out3);
\node (n8) [sum, at={($(n5)!0.5!(n7)$)}];
\coordinate[right=of n8] (out2);
% Connections
\draw   (in) edge ["${u[k]}$"]  (n1)
        (n1) edge               (n2)
        (n2) edge               (n3)
        (n3) -- (n5) edge["${y[k]}$"] (out1);
\draw[<-]   (n3.north) 
    to["${\mathcal{Z}^{-1}\Bigl\{\frac{v}{A(z)}\Bigr\}[k]}$" '] ++ 
            (0,1.1);
%
\draw[->]   (n1) |- ([yshift=-1mm] n6.west);
\draw[->]   (n4) -- (n4 |- n8) -| ([shift={(-5mm,1mm)}] n6.west) 
                 -- ([yshift=1mm] n6.west) ;
%
\draw   (n5) edge               (n8)
        (n8) edge ["${e[k]}$"]  (out2)
        (n7) edge [pos=0.9,"$-$"] (n8) 
        (n6) -- (n7) edge ["${\hat{y}[k]}$" '] (out3);
    \end{tikzpicture}
\end{document}

相关内容