1

I'm currently finalizing my Bachelor's Thesis and working with Latex and TikZ. Even though I have posed some TikZ questions that definitely helped my understanding, I am somehow stuck with this one.

enter image description here

I am somehow unable to even draw nice rectangles, I don't know whether it is the fact that I am completely new to tikz or that I didn't do tikz for over two weeks now or both.

Help would be greatly appreciated !

Here is my pathetic code, it won't even compile :(

\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
    @daleif Sorry, just updated it... – aladin Jan 14 at 13:18
  • Compiles fine if: (a) the [...] at the start goes right after \begin{tikzpicture}, no blank lines inbetween and (b) you remember to end the last 3 nodes by ; – daleif Jan 14 at 13:33
  • I would start by concentrating on the two boxed pieces of text. And then adding stuff around this. – daleif Jan 14 at 13:36
2

Here is something you can start with. There are easier ways to do this, but for beginners I like to spell things out like I do in this example. I haven't added any explanations, that is my exercise for you and I've also omitted a lot of the texts, it should be obvious from the few example in the code how these can be added

\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}

enter image description here

  • Hi, thank you! It was very nice of you to leave it to me for further understanding:) I took your template, modified it to my liking and used the template again for another slightly different picture ! Thanks a lot ! – aladin Jan 14 at 17:15
1

enter image description here

Using relative coordinates, defined styles for box, dot and sum nodes:

\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}
  • Hi Zarko my friend, thank you for your solution. I have already implemented and modified above solution from daleif, but I will consider some points you made in your code :) Thanks a lot ! – aladin Jan 14 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.