使用 Tikz 绘制矩阵

使用 Tikz 绘制矩阵

最近,我面临的任务是使用 Tikz 绘制三个矩阵并以某种方式排列它们。

https://i.stack.imgur.com/jJksz.jpg输出结果如下

我已经使用数组函数绘制了矩阵,但这并不是我真正需要的。而且,我无法真正将它们排列成输出的样子。不过,我还是向您发送了我迄今为止使用的代码:

[代码]

\documentclass[12pt]{article}     
\usepackage[english]{babel}     
\usepackage[utf8x]{inputenc}     
\usepackage{amsmath}     
\usepackage{tikz} 

\begin{document} 

\[     
\begin{array}{r@{\,}l@{\,}l@{\,}l@{\,}l} 
    & 
\left(\begin{array}{cccc} 
   x_{ii}&x_{22}& \ldots&x_{1j} \\ 
   x_{22}& x_{22}& \ldots & x_{2j}\\ 
    \vdots& \vdots & \ddots & \vdots\\ 
    x_{i1} &x_{i2} & \ldots&  x_{ij} \\ 
    \vdots&\vdots& &\vdots\\
    x_{n1}& x_{n2}&\ldots& x_{nj}\\
        \end{array}\right) 

& =
\left(\begin{array}{cccc} 
    \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
    \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
    \vdots&\vdots& \ddots&\vdots\\
    \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
     \vdots&\vdots& \ldots&\vdots\\
    \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
 \end{array}\right) 

& +
\left(\begin{array}{cccc} 
   r_{11}&r_{12}&\ldots&r_{1j}\\
   r_{21}&r_{22}&\ldots& r_{2j}\\
   \vdots&\vdots& \ddots& \vdots\\
   r_{i1}&r_{i2}&\ldots& r_{ij}\\
   \vdots&\vdots&\ldots&\vdots\\
   r_{n1}&r_{n2}& \ldots& r_{nj}\\
 \end{array}\right) 
\end{array} 
\] 
\end{document}

[/代码]

提前感谢大家

答案1

这起到了类似的作用。

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning,matrix}
\begin{document}
\begin{tikzpicture}
 \matrix[matrix of math nodes,draw] (mat1) {
    x_{ii}&x_{22}& \ldots&x_{1j} \\ 
    x_{22}& x_{22}& \ldots & x_{2j}\\ 
     \vdots& \vdots & \ddots & \vdots\\ 
     x_{i1} &x_{i2} & \ldots&  x_{ij} \\ 
     \vdots&\vdots& &\vdots\\
     x_{n1}& x_{n2}&\ldots& x_{nj}\\
 };
 \foreach \X/\Y in {1/1,2/2,4/i,6/k} 
 {\node[right=1pt of mat1-\X-4]{$\ifnum\X<6\ldots\fi x_{\Y k}$};}
 \matrix[matrix of math nodes,below=3em of mat1,draw,xshift=-1em] (mat2) {
     \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
     \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
     \vdots&\vdots& \ddots&\vdots\\
     \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
      \vdots&\vdots& \ldots&\vdots\\
     \bar{x}_{\bullet 1}&\bar{x}_{\bullet 2}& \ldots&\bar{x}_{\bullet j}\\
 };
 \node[anchor=west] at (mat2.south east){$\overline{x}\ldots$};
 \matrix[matrix of math nodes,right=4em of mat2,draw] (mat3) {
    r_{11}&r_{12}&\ldots&r_{1j}\\
    r_{21}&r_{22}&\ldots& r_{2j}\\
    \vdots&\vdots& \ddots& \vdots\\
    r_{i1}&r_{i2}&\ldots& r_{ij}\\
    \vdots&\vdots&\ldots&\vdots\\
    r_{n1}&r_{n2}& \ldots& r_{nj}\\
 };
 \foreach \X/\Y in {2/{A=B},3/{C=D}}
 {\draw[-latex] (mat1) -- (mat\X);
 \draw[-latex] (mat\X.south) -- ++ (0,-2em) node[below] (G\X) 
 {$\Y$};}
 \path (mat2) -- (mat3) node[midway]{$+$} (G2) -- (G3) node[midway,below=1.5em] (F) {$F$};
 \foreach \X/\Y in {2,3}
 {\draw[-latex] (G\X) -- (F);}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容