# How to create the following matrix with grouping structure?

I want to write the following matrix in latex,

Adding the group structure is creating some problem. Can anyone provide me with a simple code to generate the groups for the matrices?

Thank you,

Prithish.

• Please share with us what you have got so far. Provide a MWE (minimal working example) which starts at \documentclass and ends at \end{document}. – Skillmon likes topanswers.xyz Mar 23 '17 at 19:43
• Welcome to TeX. SE! Please, (i) see the last answer listed on the right of your question (as related questions) and try on it basis write code for your matrix. on this basis we can further help you to add curly braces on the right side of matrix. – Zarko Mar 23 '17 at 19:45
• possibly helpful: How to write brackets in a matrix – barbara beeton Mar 24 '17 at 19:03

Here's a solution that's uses nested array environments. \documentclass{article}
\usepackage{amsmath} % for "\text" macro
\newcommand\curlygroup{%
\left.\begin{array}{@{}c@{}}
\vphantom{x_11} \\ \vphantom{vdots} \\ \vphantom{x_11}
\end{array}\right\} \text{#1}}
\begin{document}
$\setlength\arraycolsep{2pt} \left[\begin{array}{cccc} x_{11} & x_{12} & \cdots & x_{1p} \\ \vdots & \vdots & \ddots & \vdots \\ x_{k1} & x_{k2} & \cdots & x_{kp} \\ \hline x_{k+1,1}&x_{k+1,2}& \cdots & x_{k+1,p}\\ \vdots & \vdots & \ddots & \vdots \\ x_{n1} & x_{n2} & \cdots & x_{np} \\ \end{array}\right] \begin{array}{@{}l@{}} \curlygroup{Group 1}\\[4.5ex] \curlygroup{Group 2} \end{array}$
\end{document}