Last Edit: [all three (forth just semi-automates second) ways]
\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage{anyfontsize}
\usetikzlibrary{arrows,matrix,positioning,decorations.pathreplacing,calc}
\makeatletter
\newcommand\getwidthofnode[2]{%
\pgfextractx{#1}{\pgfpointanchor{#2}{east}}%
\pgfextractx{\pgf@xa}{\pgfpointanchor{#2}{west}}% \pgf@xa is a length defined by PGF for temporary storage. No need to create a new temporary length.
\addtolength{#1}{-\pgf@xa}%
}
\makeatother
\makeatletter
\newcommand\getheightofnode[2]{%
\pgfextracty{#1}{\pgfpointanchor{#2}{north}}%
\pgfextracty{\pgf@ya}{\pgfpointanchor{#2}{south}}% \pgf@xa is a length defined by PGF for temporary storage. No need to create a new temporary length.
\addtolength{#1}{-\pgf@ya}%
}
\makeatother
\newlength\TestLength
\newlength\TestHeight
\begin{document}
% First way: No tikz but a \vphantom "trick" for the \right)
First way:
$\underbrace{\begin{aligned}
\begin{bmatrix}
x_{11} & \cdots & x_{1k} \\
\vdots & \ddots & \vdots \\
x_{n1} & \cdots & x_{nk}
\end{bmatrix}\end{aligned}
}_{k~\text{variables}}
\left.\vphantom{\begin{aligned}
\begin{bmatrix}
x_{11} & \cdots & x_{1k} \\
\vdots & \ddots & \vdots \\
x_{n1} & \cdots & x_{nk}
\end{bmatrix}\end{aligned}}\right)~\text{$n$ observations}$
\vspace*{15pt}
% Second way: tikz and brace ( manual fix of shifting)
Second way:
\begin{tikzpicture}
\node (m1) at (0,0) {$\begin{aligned}
\begin{bmatrix}
x_{11} & \cdots & x_{1k} \\
\vdots & \ddots & \vdots \\
x_{n1} & \cdots & x_{nk}
\end{bmatrix}\end{aligned}$};
\draw [thick,decorate,decoration={brace,amplitude=6pt,mirror}] ([xshift=10pt]m1.south west) --
([xshift=-10pt]m1.south east) node[midway] (m2) {};
\node [anchor=north,yshift=-6pt] at (m2) {$k$ variables};
\draw[thick,decorate,decoration={brace,amplitude=6pt,mirror}] ([yshift=6pt]m1.south east) --
([yshift=-6pt]m1.north east) node[midway] (m3) {};
\node[anchor=west,xshift=6pt] at (m3) {$n$ observations};
\end{tikzpicture}
\vspace*{15pt}
% Third way: tikz and round bracket (using "\getwidthofnode" and "\getheightofnode" to automate procedure)
Third way:
\begin{tikzpicture}
\node (m1) at (0,0) {$\begin{aligned}
\begin{bmatrix}
x_{11} & \cdots & x_{1k} \\
\vdots & \ddots & \vdots \\
x_{n1} & \cdots & x_{nk}
\end{bmatrix}\end{aligned}$};
\getwidthofnode{\TestLength}{m1}
\pgfmathsetmacro\myLength{\TestLength*0.7}
\node (m2)[yscale=0.5,rotate=-90,font=\fontsize{\myLength}{45}\selectfont] at (m1.south) {)};%yscale here is to reduce width of horizontal ")"
\node [anchor=north] at (m2) {$k$ variables};
\getheightofnode{\TestHeight}{m1}
\pgfmathsetmacro\myLength{\TestHeight*0.7}
\node (m3) [xscale=0.8,font=\fontsize{\myLength}{45}\selectfont] at ($(m1)+(\TestLength/2,0)$) {)};%xscale here is to reduce width of vertical ")"
\node (m4) at (m3) {\phantom{$n$ observations}};
\getwidthofnode{\TestLength}{m4}
\node at ($(m4)+(\TestLength/2,0)$) {$n$ observations};
\end{tikzpicture}
\vspace*{15pt}
% Fourth way: tikz and brace (using "\getwidthofnode" and "\getheightofnode" to semi-automate procedure)
Fourth way:
\begin{tikzpicture}
\xdef\MatrixToBraceXSouthScale{0.7}
\xdef\MatrixToBraceYEastScale{0.7}
\node (m1) at (0,0) {$\begin{aligned}
\begin{bmatrix}
x_{11} & \cdots & x_{1k} \\
\vdots & \ddots & \vdots \\
x_{n1} & \cdots & x_{nk}
\end{bmatrix}\end{aligned}$};
\getwidthofnode{\TestLength}{m1}
\pgfmathsetmacro\myWidth{\TestLength/2}
\getheightofnode{\TestLength}{m1}
\pgfmathsetmacro\myHeight{\TestLength/2}
\draw [thick,decorate,decoration={brace,amplitude=6pt,mirror}] ($(m1)-({\myWidth*\MatrixToBraceXSouthScale pt},{\myHeight pt})$)--
($(m1)+({\myWidth*\MatrixToBraceXSouthScale pt},{-\myHeight pt})$) node[midway](m2) {};
\node [anchor=north,yshift=-7pt] at (m2) {$k$ variables};
\draw [thick,decorate,decoration={brace,amplitude=6pt,mirror}] ($(m1)+({\myWidth pt},{-\myHeight*\MatrixToBraceYEastScale pt})$)--
($(m1)+({\myWidth pt},{\myHeight*\MatrixToBraceYEastScale pt})$) node [midway](m3){};
\node[anchor=west,xshift=6pt] at (m3) {$n$ observations};
\end{tikzpicture}
\end{document}
Used @Caramdir's solution of \widthof within tikzpicture
Results:
