3

Please how can I draw the figure shown below in Latex? I copied the figure from a journal. I am currently using Tikz package. Thank you for your help.

Update:

My code is shown below.

\begin{tikzpicture}
 
% Zero order block 
\node[draw,
    minimum width=2cm,
    minimum height=1.2cm,
] (ZOH) at (0,0){$Hold (H)$};

% High altitude balloon block
\node [draw, 
    minimum width=2cm, 
    minimum height=1.2cm, 
    above right= 0.5cm and 1cm of ZOH
]  (plant) {Plant (G) $\dot{x} = f(x(t), u(t), w(t))$};

% Sampler
\node [draw, 
    minimum width=2cm, 
    minimum height=1.2cm, 
    below right= 0.5cm and 1cm of plant
]  (sampler) {Sampler $[k]$};

% Extremum seeking controller
\node [draw, 
    minimum width=2cm, 
    minimum height=1.2cm, 
    below right= 0.5cm and 1cm of ZOH] 
     (ESC) {Controller (K) ;
          $\hat{u}_j = K(\hat{x}_j)$ };

% Arrows with text label
\draw[-stealth] (ZOH.north) |- (plant.west)
    node[near end,above]{$u(t)$};

\draw[-stealth] (plant.east) -| (sampler.north)
    node[near start,above]{$x(t)$}; 

\draw[-stealth] (sampler.south) |- (ESC.east)
    node[near end,below]{$J[k]$};   

\draw[-stealth] (ESC.west) -| (ZOH.south)
    node[near start,below]{$\hat{u}_j$};        

\end{tikzpicture}

enter image description here

7
  • If you are already using the TikZ package, show what you got so far, so we know better how to help you! Aug 5, 2022 at 20:07
  • If you are using Tikz and can produce this, what are you asking? do you have any code for people to look at?
    – Paul A
    Aug 5, 2022 at 20:08
  • @JasperHabicht Thank you for the comment. I have updated the question with my current code.
    – Tee
    Aug 5, 2022 at 20:16
  • Okay, so what exactly is your question now? What you got looks already quite good Aug 5, 2022 at 20:24
  • His question is how to fix his diagram. If you compile the code he made, you will see how it doesn’t match the diagram in the picture he put. Aug 5, 2022 at 21:12

1 Answer 1

4

Hope this helps:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta}

\begin{document}

\begin{tikzpicture}[>=stealth]
 
% Zero order block 
\node[draw=black!50,ultra thick,
minimum width=2.2cm,
minimum height=1cm,fill=cyan!30] (ZOH) at (0,0){Hold $(H)$};

% High altitude balloon block
\node [draw=black!50, 
    minimum width=2cm, 
    minimum height=1.5cm, 
    above right= 0.5cm and 1cm of ZOH,
    align=center, ultra thick,fill=cyan!30
]  (plant) {Plant (G)\\$\dot{x}(t) = f(x(t), u(t), w(t))$};

% Sampler
\node [draw=black!50, 
    minimum width=2cm, 
    minimum height=1.2cm, 
    below right= 0.5cm and 1cm of plant, ultra thick,fill=cyan!30,
    align=center
]  (sampler) {Sampler $(S)$\\sampling instants, $\{r_j\}$};

% Extremum seeking controller
\node [draw=black!50, 
    minimum width=3cm, 
    minimum height=1.5cm, ultra thick, fill=cyan!30,
    below right= 0.5cm and 1.6cm of ZOH,
    align=center] 
     (ESC) {Controller (K)\\
    $\hat{u}_j = K(\hat{x}_j)$ };

% Arrows with text label
\draw[->,ultra thick] (ZOH.north) |- (1.9,1.7);
\draw (-0.5,1.7) node {$u(t)$};

\draw[->,ultra thick] (plant.east) -| (sampler.north)
    node[near start,above]{$x(t)$}; 

\draw[->,ultra thick] (sampler.south) |- (ESC.east)
    node[near end,below right]{$\hat{x}_j=x(r_j)$};   

\draw[->,ultra thick] (ESC.west) -| (ZOH.south)
    node[near end,left]{$\hat{u}_j$};   
\draw[->, ultra thick] (0,2.2) node[anchor=east] {$w(t)$} -- (1.9,2.2);

\end{tikzpicture}

\end{document}

image

The key for the linebreaks in the node text was to use align=center. Then I just changed the thickness of the lines and arrows, and moved some of the nodes around, changed the colors, and then of course, added the extra arrow near the top left.

3
  • Update: You can use \widehat instead of \hat to get a better arrow, for example \widehat{{x}_j}=x(r_j). Aug 5, 2022 at 22:34
  • You should use styles to simplify a lttile the code.
    – projetmbc
    Aug 6, 2022 at 7:41
  • 1
    I thought of that but decided not just because I’d have to rewrite a bunch Aug 6, 2022 at 14:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .