我想画一个如下图所示的图表。到目前为止,我写了这个。你能帮我修改一下这段代码吗?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz, pgfplots}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (8,4);
\draw (2,1) rectangle (6,3);
\node[] at (-2,2) {$\dot{x}_i(t_0)$};
\node[] at (-1,1.5) { Input};
\draw[->] (-1.5,2) -- (0,2);
\node[] at (0.6,3.8) {$\theta_1=0$};
\draw[->] (1,2) -- (2,2);
\node[] at (2, 3.4) {$\theta_{i+1}(t_0)=x_i(t_0)+\theta_1(t_0)$};
\node[] at (0.5,2) {$\theta_i(t_0)$};
\draw[->] (6,2) -- (7,2);
\node[] at (7.5,2) {$\dot{\theta_i}(t_0)$};
\draw[->] (6,2) -- (7,2);
\draw[->] (8,2) -- (10,2);
\node[] at (10.5,2) {$\dot{x_i}(t_0)$};
\end{tikzpicture}
\end{document}
答案1
我不确定期望的结果或答案,但我认为使用nodes
均匀坐标rectangles
并忘记固定坐标可以简化绘图任务。
一个可能的替代方案:
\documentclass[tikz]{standalone}
\usetikzlibrary{fit, positioning}
\begin{document}
\begin{tikzpicture}
\node[minimum width=4cm, minimum height=2cm, draw] (inner) {};
\draw[->] (inner.east)--++(0:1cm) node[right](thetadot){$\dot{\theta_i}(t_0)$};
\draw[<-] (inner.west)--++(180:1cm) node[left](theta){$\theta_i(t_0)$};
\node[fit=(theta) (thetadot), minimum height=4cm, draw] (outer) {};
\draw[->] (outer.east)--++(0:1cm) node[right] (x-in){$\dot{x_i}(t_0)$};
\draw[<-] (outer.west)-- node[below]{Input} ++(180:1cm) node[left] (x-out){$\dot{x_i}(t_0)$};
\node[below right=1pt and 1pt of outer.north west, align=left]{$\theta_1=0$\\$\theta_{i+1}(t_o)=x_i(t_0)+\theta_1(t_0)$};
\end{tikzpicture}
\end{document}