[Tex/LaTex] how to draw a stair matrix using tikZ in Beamer

beamermatricestikz-matrix

I am very new to Beamer and LaTeX. I want to draw a stairs matrix as attached. It should be pretty simple but I just don't know how to draw it. Please only use tikZ (and matrix) and don't use other library. Thanks very much![enter image description here]1

Best Answer

Reasonably minimal:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\tikz[x=1em, y=1em, inner sep=1em/6]]
  \matrix [left delimiter={[}, right delimiter={]}] {
  \draw (0,0) \foreach \i [count=\j] in {1,2,1,3,1,2,2,1,1}{ 
    \ifnum\j>1-- ++(0,-1)\fi node [above right] (x-\j) {$x$} -- ++(\i,0)
  }
  (x-1 -| x-\j) node [left]  {possibly nonzero entries}
  (x-1 |- x-\j) node [right] {zero entries};
\\};
\end{document}

enter image description here