创建一个大矩阵

创建一个大矩阵

我需要创建这个

在此处输入图片描述

但我不知道该怎么做因为我只是一个初学者。

\usepackage{tabu}   
\begin{document}                                                                                                              \[{\tiny \left(
\tabulinestyle{on 4pt off 4pt}
\begin{tabu}{cccc|cccc|cccc}
 d_{1,1} & -AX_{1+\frac{1}{2},1} & 0 & 0 & -AY_{1,1-\frac{1}{2}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
-AX_{1+\frac{1}{2},1} & d_{2,1} & -AX_{2+\frac{1}{2},1} & 0 & 0 & -AY_{2,1-\frac{1}{2}} & 0 & 0 & 0 & 0 & 0 & 0 \\
 0 & -AX_{2+\frac{1}{2},1} & d_{3,1} & -AX_{3+\frac{1}{2},1} & 0 & 0 & -AY_{3,1-\frac{1}{2}} & 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & -AX_{3+\frac{1}{2},1} & d_{4,1} & 0 & 0 & 0 & -AY_{4,1-\frac{1}{2}} & 0 & 0 & 0 & 0 \\
-AY_{1,1-\frac{1}{2}} &0 & 0 & 0 & d_{1,2} & -AX_{1+\frac{1}{2},2} & 0 & 0 & -AY_{1,2-\frac{1}{2}} & 0 & 0 & 0 \\ \tabucline-

0 & -AY_{2,1-\frac{1}{2}} & 0 & 0 & -AX_{1+\frac{1}{2},2} & d_{2,2} & -AX_{2+\frac{1}{2},2} & 0 & 0 & -AY_{2,2-\frac{1}{2}} & 0 & 0 \\
0 & 0 & -AY_{3,1-\frac{1}{2}} & 0 & 0 & -AX_{2+\frac{1}{2},2} & d_{3,2} & -AX_{3+\frac{1}{2},2} & 0 & 0 & -AY_{3,2-\frac{1}{2}} & 0 \\
0 & 0 & 0 & -AY_{4,1-\frac{1}{2}} & 0 & 0 & -AX_{3+\frac{1}{2},2} & d_{4,2} & 0 & 0 & 0 & -AY_{4,2-\frac{1}{2}} \\ \tabucline-
0 & 0 & 0 & 0 & -AY_{1,2-\frac{1}{2}} & 0 & 0 & 0 & d_{1,3} & -AX_{1+\frac{1}{2},3} & 0 & 0 \\

0 & 0 & 0 & 0 & 0 & -AY_{2,2-\frac{1}{2}} & 0 & 0 & -AX_{1+\frac{1}{2},3} & d_{2,3} & -AX_{2\frac{1}{2},3} & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & -AY_{3,2-\frac{1}{2}} & 0 & 0 & -AX_{2+\frac{1}{2},3} & d_{3,3} & -AX_{3+\frac{1}{2},3} \\ 
0 & 0 & 0 & 0 & 0 & 0 & 0 & - AY_{4,2-\frac{1}{2}} & 0 & 0 & -AX_{3+\frac{1}{2},3} & d_{4,3} 
\end{tabu}\right)
\left( \tabulinestyle{on 1pt off 1pt}
\begin{tabu}{c}
P_{1,1}\\ P_{2,1}\\ P_{3,1}\\ P_{4,1}\\ \tabucline-
P_{1,2}\\ P_{2,2}\\ P_{3,2}\\ P_{4,2}\\ \tabucline-
P_{1,3}\\ P_{2,3}\\ P_{3,3}\\ P_{4,3}\end{tabu}
\right)}
\]

在此处输入图片描述

答案1

一种使用 TikZ 的方法,在我看来,它产生的结果更易于阅读:

矩阵

这是代码:

\documentclass[a4paper, landscape]{article}
\usepackage[margin=5mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning,calc}
\begin{document}

\def\linebelowrow#1#2{%
  \pgfmathsetmacro{\nextrow}{int(#2+1)}
  \coordinate (aux) at ($(#1-#2-1.center)!.5!(#1-\nextrow-1.center)$);
  \draw[dashed] (#1.west|-aux) -- (#1.east|-aux);
}
\def\lineaftercolumn#1#2{%
  \pgfmathsetmacro{\nextcol}{int(#2+1)}
  \coordinate (aux) at ($(#1-1-#2.center)!.5!(#1-1-\nextcol.center)$);
  \draw[dashed] (#1.north-|aux) -- (#1.south-|aux);
}
\begin{tikzpicture}
\matrix[matrix of math nodes, left delimiter={[},
        right delimiter={]}, nodes={minimum height=5ex, inner sep=0pt}, row sep=1ex] (M) {
 d_{1,1} & -AX_{1+\frac{1}{2},1} & 0 & 0 & -AY_{1,1-\frac{1}{2}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
-AX_{1+\frac{1}{2},1} & d_{2,1} & -AX_{2+\frac{1}{2},1} & 0 & 0 & -AY_{2,1-\frac{1}{2}} & 0 & 0 & 0 & 0 & 0 & 0 \\
 0 & -AX_{2+\frac{1}{2},1} & d_{3,1} & -AX_{3+\frac{1}{2},1} & 0 & 0 & -AY_{3,1-\frac{1}{2}} & 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & -AX_{3+\frac{1}{2},1} & d_{4,1} & 0 & 0 & 0 & -AY_{4,1-\frac{1}{2}} & 0 & 0 & 0 & 0 \\
-AY_{1,1-\frac{1}{2}} &0 & 0 & 0 & d_{1,2} & -AX_{1+\frac{1}{2},2} & 0 & 0 & -AY_{1,2-\frac{1}{2}} & 0 & 0 & 0 \\
0 & -AY_{2,1-\frac{1}{2}} & 0 & 0 & -AX_{1+\frac{1}{2},2} & d_{2,2} & -AX_{2+\frac{1}{2},2} & 0 & 0 & -AY_{2,2-\frac{1}{2}} & 0 & 0 \\
0 & 0 & -AY_{3,1-\frac{1}{2}} & 0 & 0 & -AX_{2+\frac{1}{2},2} & d_{3,2} & -AX_{3+\frac{1}{2},2} & 0 & 0 & -AY_{3,2-\frac{1}{2}} & 0 \\
0 & 0 & 0 & -AY_{4,1-\frac{1}{2}} & 0 & 0 & -AX_{3+\frac{1}{2},2} & d_{4,2} & 0 & 0 & 0 & -AY_{4,2-\frac{1}{2}} \\
0 & 0 & 0 & 0 & -AY_{1,2-\frac{1}{2}} & 0 & 0 & 0 & d_{1,3} & -AX_{1+\frac{1}{2},3} & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & -AY_{2,2-\frac{1}{2}} & 0 & 0 & -AX_{1+\frac{1}{2},3} & d_{2,3} & -AX_{2\frac{1}{2},3} & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & -AY_{3,2-\frac{1}{2}} & 0 & 0 & -AX_{2+\frac{1}{2},3} & d_{3,3} & -AX_{3+\frac{1}{2},3} \\ 
0 & 0 & 0 & 0 & 0 & 0 & 0 & - AY_{4,2-\frac{1}{2}} & 0 & 0 & -AX_{3+\frac{1}{2},3} & d_{4,3} \\
};
\matrix [matrix of math nodes, left delimiter={[}, right delimiter={]},
         right=2em of M.east, nodes={minimum height=5.5ex, inner sep=0pt}, 
         row sep=1ex] (P) {
P_{1,1}\\ P_{2,1}\\ P_{3,1}\\ P_{4,1}\\ 
P_{1,2}\\ P_{2,2}\\ P_{3,2}\\ P_{4,2}\\ 
P_{1,3}\\ P_{2,3}\\ P_{3,3}\\ P_{4,3} \\
};

\node[right=1em of P] (equal) {$=$};

\matrix[matrix of math nodes, left delimiter={[}, right delimiter={]},
         right=1em of equal, nodes={minimum height=5.5ex, inner sep=0pt}, 
         row sep=1ex] (O) {
O_{1,1}\\ O_{2,1}\\ O_{3,1}\\ O_{4,1}\\ 
O_{1,2}\\ O_{2,2}\\ O_{3,2}\\ O_{4,2}\\ 
O_{1,3}\\ O_{2,3}\\ O_{3,3}\\ O_{4,3} \\
};

\linebelowrow{M}{4}\linebelowrow{M}{8}
\lineaftercolumn{M}{4}\lineaftercolumn{M}{8}
\linebelowrow{P}{4}\linebelowrow{P}{8}
\linebelowrow{O}{4}\linebelowrow{O}{8}

\end{tikzpicture}
\end{document}

请注意,无论如何,此代码还会生成一个太大而无法放入一页的矩阵。但这个问题出在矩阵中,而不是您用来排版的工具中。如果您将图形缩小太多,子索引将无法读取。我会选择横向页面来显示此矩阵,或者选择一种更紧凑的方式来表示它,即通过子矩阵,这些子矩阵可以在不同的公式中单独显示。

答案2

如果您需要的只是调整表格大小,那么请使用命令\resizebox

梅威瑟:

\begin{table}
\resizebox{0.5\linewidth}{!}
{%
\[{\tiny \left(
\tabulinestyle{on 4pt off 4pt}
\begin{tabu} {|cccc|cccc|cccc|}%
%
 d_{1,1} & -AX_{1+\frac{1}{2},1} & 0 & 0 & -AY_{1,1-\frac{1}{2}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
-AX_{1+\frac{1}{2},1} & d_{2,1} & -AX_{2+\frac{1}{2},1} & 0 & 0 & -AY_{2,1-\frac{1}{2}} & 0 & 0 & 0 & 0 & 0 & 0 \\
 0 & -AX_{2+\frac{1}{2},1} & d_{3,1} & -AX_{3+\frac{1}{2},1} & 0 & 0 & -AY_{3,1-\frac{1}{2}} & 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & -AX_{3+\frac{1}{2},1} & d_{4,1} & 0 & 0 & 0 & -AY_{4,1-\frac{1}{2}} & 0 & 0 & 0 & 0 \\
-AY_{1,1-\frac{1}{2}} &0 & 0 & 0 & d_{1,2} & -AX_{1+\frac{1}{2},2} & 0 & 0 & -AY_{1,2-\frac{1}{2}} & 0 & 0 & 0 \\ \tabucline-

0 & -AY_{2,1-\frac{1}{2}} & 0 & 0 & -AX_{1+\frac{1}{2},2} & d_{2,2} & -AX_{2+\frac{1}{2},2} & 0 & 0 & -AY_{2,2-\frac{1}{2}} & 0 & 0 \\
0 & 0 & -AY_{3,1-\frac{1}{2}} & 0 & 0 & -AX_{2+\frac{1}{2},2} & d_{3,2} & -AX_{3+\frac{1}{2},2} & 0 & 0 & -AY_{3,2-\frac{1}{2}} & 0 \\
0 & 0 & 0 & -AY_{4,1-\frac{1}{2}} & 0 & 0 & -AX_{3+\frac{1}{2},2} & d_{4,2} & 0 & 0 & 0 & -AY_{4,2-\frac{1}{2}} \\ \tabucline-
0 & 0 & 0 & 0 & -AY_{1,2-\frac{1}{2}} & 0 & 0 & 0 & d_{1,3} & -AX_{1+\frac{1}{2},3} & 0 & 0 \\

0 & 0 & 0 & 0 & 0 & -AY_{2,2-\frac{1}{2}} & 0 & 0 & -AX_{1+\frac{1}{2},3} & d_{2,3} & -AX_{2\frac{1}{2},3} & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & -AY_{3,2-\frac{1}{2}} & 0 & 0 & -AX_{2+\frac{1}{2},3} & d_{3,3} & -AX_{3+\frac{1}{2},3} \\ 
0 & 0 & 0 & 0 & 0 & 0 & 0 & - AY_{4,2-\frac{1}{2}} & 0 & 0 & -AX_{3+\frac{1}{2},3} & d_{4,3} 
\end{tabu}\right)
\left(\tabulinestyle{on 1pt off 1pt}
\begin{tabu}{c}
P_{1,1}\\ P_{2,1}\\ P_{3,1}\\ P_{4,1}\\ \tabucline-
P_{1,2}\\ P_{2,2}\\ P_{3,2}\\ P_{4,2}\\ \tabucline-
P_{1,3}\\ P_{2,3}\\ P_{3,3}\\ P_{4,3}
\end{tabu}
\right)}
\]
}
\end{table}

结果

相关内容