Re: Combine matrices of equal height
- To: mathgroup at smc.vnet.net
- Subject: [mg111034] Re: Combine matrices of equal height
- From: "David Park" <djmpark at comcast.net>
- Date: Sun, 18 Jul 2010 01:02:15 -0400 (EDT)
Here are two sample matrices. m1 = Array[1 &, {3, 2}]; m2 = Array[2 &, {3, 3}]; Transpose[Join[Transpose[m1], Transpose[m2]]] // MatrixForm Another method that doesn't explicitly use Join and Transpose is to make a new blank matrix first and then fill in the parts using the Span notation. This might be more intuitive. m3 = Array[0 &, {3, 5}]; m3[[All, 1 ;; 2]] = m1; m3[[All, 3 ;; 5]] = m2; m3 // MatrixForm David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: Sam Takoy [mailto:sam.takoy at yahoo.com] Hi, Given two matrices of equal height, what's the best way to combine them. Here's what I did TF[m_] := Flatten[Transpose[m]] Combine[m1_, m2_] := Partition[Join[m1 // TF, m2 // TF], Length[m1]] // T Surely there's a better way of doing it. Thanks!