MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Combine matrices of equal height

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111051] Re: Combine matrices of equal height
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Sun, 18 Jul 2010 01:05:21 -0400 (EDT)
  • References: <i1s6v2$a2g$1@smc.vnet.net>

On Jul 17, 5:16 am, Sam Takoy <sam.ta... at yahoo.com> wrote:
> 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!

m1 = {{11,12},
      {21,22}};
m2 = {{13,14,15},
      {23,24,25}};
m3 = {{16,17},
      {26,27}};
MapThread[Join,{m1,m2,m3}]

{{11,12,13,14,15,16,17},
 {21,22,23,24,25,26,27}}


  • Prev by Date: Misprint
  • Next by Date: Re: Generate #s
  • Previous by thread: Re: Combine matrices of equal height
  • Next by thread: Re: Combine matrices of equal height