4
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ 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! $\endgroup$
    – user9660
    Nov 13, 2015 at 15:14
  • $\begingroup$ Have a look at mathematica.stackexchange.com/q/3069/131. I suspect everything is already available there. $\endgroup$
    – Yves Klett
    Nov 13, 2015 at 15:20
  • $\begingroup$ ArrayFlatten is what you need. $\endgroup$ Nov 13, 2015 at 15:26

1 Answer 1

4
$\begingroup$

Like this?

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

enter image description here

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

enter image description here

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

enter image description here

$\endgroup$
2
  • 8
    $\begingroup$ Join[a, b, 2] $\endgroup$
    – ybeltukov
    Nov 13, 2015 at 15:38
  • $\begingroup$ Perfect! Thank you! $\endgroup$
    – Sertii
    Nov 13, 2015 at 15:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.