MathGroup Archive 2006

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

Search the Archive

Re: Combining Matrices

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65028] Re: [mg65017] Combining Matrices
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 12 Mar 2006 23:57:45 -0500 (EST)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

n=3;p=4;q=2;
A=Array[a,{n,p}];
B=Array[b,{n,q}];

X=Join@@@Thread[{A,B}]

X=Join@@@Transpose[{A,B}]

Needs["LinearAlgebra`MatrixManipulation`"];

X=AppendRows[A,B]

Needs["Statistics`DataManipulation`"];

X=RowJoin[A,B]


Bob Hanlon

> 
> From: Gregory Lypny <gregory.lypny at videotron.ca>
To: mathgroup at smc.vnet.net
> Subject: [mg65028] [mg65017] Combining Matrices
> 
> Hello Everyone,
> 
> I'm trying to figure out how to combine an n x p matrix and an n x q  
> matrix to form an n x (p + q) matrix.  I found one way, shown in the  
> second last line of the code below, but I have no idea why it works,  
> and I'm wondering whether there is a more direct way.  The example  
> takes 3 x 4 matrix A and combines it with 3 x 2 matrix B to form 3 x  
> 6 matrix X.
> 
> Any thoughts would be most appreciated.
> 
> 	Gregory
> 
> Clear[X]
> n = 3; p = 4; q = 2;
> A = Array[a, {n, p}];
> B = Array[b, {n, q}];
> (X = Transpose[Flatten[{{Transpose[A], Transpose[B]}}, 2]]) //  
> MatrixForm
> Dimensions[X]
> 
> 


  • Prev by Date: Re: Graphics3D polygon face colors
  • Next by Date: Re: how can I import my datas in excel to mathematica and then do calculations on them?
  • Previous by thread: Re: Combining Matrices
  • Next by thread: Importing Several sheets from one Excel file into Mathematica