[Date Index]
[Thread Index]
[Author Index]
Re: Combine matrices of equal height
*To*: mathgroup at smc.vnet.net
*Subject*: [mg111058] Re: Combine matrices of equal height
*From*: Bob Hanlon <hanlonr at cox.net>
*Date*: Sun, 18 Jul 2010 01:06:38 -0400 (EDT)
TF[m_] := Flatten[Transpose[m]]
Combine[m1_, m2_] :=
Partition[Join[m1 // TF, m2 // TF], Length[m1]] // TF
Combine2[m1_, m2_] :=
Flatten[Transpose[Join[Transpose[m1], Transpose[m2]]]]
Combine3[m1_, m2_] := Flatten[Riffle[m1, m2]]
m1 = Array[x, {3, 4}];
m2 = Array[y, {3, 4}];
Combine[m1, m2] == Combine2[m1, m2] == Combine3[m1, m2]
True
Bob Hanlon
---- Sam Takoy <sam.takoy 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!
Prev by Date:
**Re: Hatched shading?**
Next by Date:
**Re: How to parametrize a block of commands?**
Previous by thread:
**Re: Combine matrices of equal height**
Next by thread:
**Re: Combine matrices of equal height**
| |