Try to understand following code.
\documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning, shapes.geometric, matrix} \begin{document} \[ A = \left[ \begin{tikzpicture}[% baseline, triangle/.style={% draw, fill=gray!50, minimum width=1.4142cm, inner sep=0pt, isosceles triangle, isosceles triangle apex angle=90, shape border uses incircle, shape border rotate=#1}, rect/.style={% draw, fill=gray!50} ] \matrix (A) [matrix, row sep=1mm, column sep=2mm] { \node[triangle=45, anchor=north] (a11) {$a_1$}; & \node[rect, minimum height=1cm, anchor=north] (a12) {$y_1$}; & \node[triangle=135, anchor=north] (a13) {$a_2$}; \\ \node[] {$o$}; & \node[rect, minimum height=1cm] (a22) {$y_1$}; & \node[] {$o$};\\ \node[triangle=-45, anchor=south] (a31) {$a_3$}; & \node[rect, minimum height=1cm, anchor=south] (a32) {$y_2$}; & \node[triangle=-135, anchor=south] (a33) {$a_4$}; \\ }; \end{tikzpicture} \right] \\ A = \left[ \begin{tikzpicture}[% baseline, triangle/.style={% % fill=gray!50, minimum width=1.4142cm, inner sep=0pt, isosceles triangle, isosceles triangle apex angle=90, shape border uses incircle, shape border rotate=#1}, rect/.style={% % fill=gray!50 } ] \matrix (A) [matrix, row sep=0pt, column sep=0pt] { \node[triangle=45, anchor=north] (a11) {$a_1$}; & \node[rect, minimum height=1cm, anchor=north] (a12) {$y_1$}; & \node[triangle=135, anchor=north] (a13) {$a_2$}; \\ \node[] {$o$}; & \node[rect, minimum height=1cm] (a22) {$y_1$}; & \node[] {$o$};\\ \node[triangle=-45, anchor=south] (a31) {$a_3$}; & \node[rect, minimum height=1cm, anchor=south] (a32) {$y_2$}; & \node[triangle=-135, anchor=south] (a33) {$a_4$}; \\ }; \draw (a11.left corner)--(a13.right corner)--(a22.north east)--(a22.south east)--(a33.left corner)--(a31.right corner)--(a22.south west)--(a22.north west)--cycle; \draw[dashed] (a11.left corner|-a22.north)--(a13.right corner|-a22.north); \draw[dashed] (a11.left corner|-a22.south)--(a13.right corner|-a22.south); \draw[dashed] (A.north-|a22.west)--(A.south-|a22.west); \draw[dashed] (A.south-|a22.east)--(A.north-|a22.east); \end{tikzpicture} \right] \] \end{document}
