Re: Concatenate matrices
- To: mathgroup at smc.vnet.net
- Subject: [mg51447] Re: Concatenate matrices
- From: Marcus Stollsteimer <marcus314 at yahoo.com>
- Date: Sun, 17 Oct 2004 03:06:37 -0400 (EDT)
- References: <ckqmb1$nb0$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thomas Guignard wrote: > Hi all > > Does someone know if there is a function in Mathematica to simply > concatenate matrices (provided their dimensions are right). Hi Thomas, I use these functions: JoinMatrices[m_?MatrixQ,l_?MatrixQ]:= Join[Transpose[m],Transpose[l]]//Transpose AddCol[m_?MatrixQ,l_?VectorQ]:=Append[Transpose[m],l]//Transpose AddCol[m_?VectorQ,l_?VectorQ]:=Append[{m},l]//Transpose m = {{1, 3}, {2, 4}}; l = {5, 6}; n = {{5, 7}, {6, 8}}; JoinMatrices[m,n] AddCol[m,l] AddCol[l,l] Out= {{1,3,5,7},{2,4,6,8}} {{1,3,5},{2,4,6}} {{5,5},{6,6}} Regards, Marcus -- The truth is rarely pure and never simple. -- Oscar Wilde