# Building a matrix in block matrix format

How to enter matrices in block matrix format?

How to form a block-diagonal Matrix from a list of matrices?

But I wasn't able to find the solution to my problem there. I need to make a matrix $$\begin{pmatrix} C_1 &I\\ 0 & C_2 \end{pmatrix}$$

My problem is that $C_1$ and $C_2$ are of different sizes! $C_1$ is of size 30 and $C_2$ is of size 48. So one would expect the following code to work:

MatrixForm[ArrayFlatten[{{c1, IdentityMatrix, 0}, {0, c2}}]]


or maybe

MatrixForm[ArrayFlatten[{{c1, IdentityMatrix, ConstantArray[0,{18,18}]},
{ConstantArray[0,{30,30}], c2}}]]


But neither actually works!

### Edit

I ended up using J.M's answer:

ArrayFlatten[{{c1, PadRight[IdentityMatrix, {Automatic, 48}]}, {0, c2}}]]

• Why not ArrayFlatten[{{c1, IdentityMatrix}, {0, c2}}]? Nov 23 '15 at 13:59
• this doesn't work either :( Nov 23 '15 at 14:03
• Try ArrayFlatten[{{c1, PadRight[IdentityMatrix, {Automatic, 48}]}, {0, c2}}]] then. Nov 23 '15 at 14:09
• Awesome! That worked! Nov 23 '15 at 14:10
• Yes they are both square. C1 and C2 are companion matrices and i'm trying to make the Jordan rational normal form. I don't think there is a problem, I might be wrong though Nov 23 '15 at 14:15

m30 = ConstantArray[3, {30, 30}];

• They are different answers, J.M.'s follows the idea that C1 and C2 have no columns in common - which can be inferred from your sketch above. Eldo's answer maintains the fact that I is an identity matrix. You can't have both: if I is an identity matrix, then the shape described doesn't make sense Nov 23 '15 at 14:25