MathGroup Archive 2004

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

Search the Archive

Re: Concatenate matrices

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51424] Re: Concatenate matrices
  • From: "Curt Fischer" <crf3 at po.cwru.edu>
  • Date: Sun, 17 Oct 2004 03:05:08 -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).
>
> Example:
>
>      / e11  e12  e13 \
> E = | e21  e22  e23 |
>      \ e31  e32  e33 /
>
>      / f11  f12 \
> F = | f21  f22 |
>      \ f31  f32 /
>
> I'd like to have:
>
>      / e11  e12  e13  f11  f12 \
> R = | e21  e22  e23  f21  f22 |
>      \ e31  e32  e33  f31  f32 /

I don't know of a simple built-in function to do this, but it is easy to
write your own.

In[1]:=
a={{a11,a12,a13},{a21,a22,a23}};

In[2]:=
b={{b11,b12},{b21,b22}};

In[3]:=
concatenateMat[matA_?MatrixQ,matB_?MatrixQ]:=MapThread[Join,{matA,matB},1]

In[4]:=
concatenateMat[a,b]

Out[4]=
{{a11,a12,a13,b11,b12},{a21,a22,a23,b21,b22}}

-- 
Curt Fischer




  • Prev by Date: Re: LegendreP (Symbolic) is different in Mathematica5 than previous versions (M4, M3 ..)
  • Next by Date: Re: Integrate vs. NIntegrate
  • Previous by thread: Re: Concatenate matrices
  • Next by thread: Re: Concatenate matrices