Re: Merge of Matrices
- To: mathgroup at smc.vnet.net
- Subject: [mg71152] Re: Merge of Matrices
- From: "astanoff" <astanoff at gmail.com>
- Date: Thu, 9 Nov 2006 03:38:56 -0500 (EST)
- References: <eisglr$nf9$1@smc.vnet.net>
On 8 nov, 12:56, Robert Berger <rberge... at sinh.us> wrote: > Hello! > > I like to create from the four matrices A (N1 rows and N1 columns), > B (N1 rows and N2 columns), C (N2 rows and N1 columns), > D (N2 rows and N2 columns) a new matrix X of the form > > A B > X = > C D > > Once A & B and C & D have been merged, the first (A & B) and the > second row (C& D) can be merged in that way by applying Join, which is > not a problem but how can I merge A & B (and of course C & D) in > that way? > > Kindly regards, > Roman. Example : In[1]:=n1=2; n2=3; In[2]:=aa=Array[a,{n1,n1}]; bb=Array[b,{n1,n2}]; In[3]:=cc=Array[c,{n2,n1}]; dd=Array[d,{n2,n2}]; In[4]:=x=Array[0&,{n1+n2,n1+n2}]; In[5]:=x[[Range[1,n1],Range[1,n1]]] = aa; x[[Range[1,n1],Range[n1+1,n1+n2]]] = bb; x[[Range[n1+1,n1+n2],Range[1,n1]]] = cc; x[[Range[n1+1,n1+n2],Range[n1+1,n1+n2]]] = dd; In[9]:=x Out[9]={ {a[1,1],a[1,2],b[1,1],b[1,2],b[1,3]}, {a[2,1],a[2,2],b[2,1],b[2,2],b[2,3]}, {c[1,1],c[1,2],d[1,1],d[1,2],d[1,3]}, {c[2,1],c[2,2],d[2,1],d[2,2],d[2,3]}, {c[3,1],c[3,2],d[3,1],d[3,2],d[3,3]}} hth V.Astanoff