# How do I put matrices next to each other? [duplicate]

So I want to be able to put matrices "next to each other", or in other words if I have two matrices $A$ that is $n\times k$ and $B$ that is $n\times m$, I want to be able to create a matrix $C$ that is $n\times (k+m)$ so that the $(k+1)$th column of $C$ is the first column of $B$.

This should be really easy, and in matlab it is (C= [A B]), but I can't figure it out in mathematica

• Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– user9660
Nov 13, 2015 at 15:14
• Have a look at mathematica.stackexchange.com/q/3069/131. I suspect everything is already available there. Nov 13, 2015 at 15:20
• ArrayFlatten is what you need. Nov 13, 2015 at 15:26

Like this?

(a = ConstantArray["A", {4, 3}]) // MatrixForm


(b = ConstantArray["B", {4, 4}]) // MatrixForm


Map[Flatten, Transpose[{a, b}]] // MatrixForm


• Join[a, b, 2] Nov 13, 2015 at 15:38
• Perfect! Thank you! Nov 13, 2015 at 15:40