Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Mata question: putting matrices along the diagonal


From   <mjbaker@hunter.cuny.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Mata question: putting matrices along the diagonal
Date   Thu, 27 May 2010 14:02:43 -0400 (EDT)

Dear Listers:

I am interested in making one large "diagonal" matrix out of a bunch of matrices in Mata. For example, suppose I have 3 2x2 matrices labeled m1, m2, and m3. I want to construct the matrix M, where M is something like:
M=
(m1[1,1],m1[1,2],     0,        0,           0, 0               \ 
 m1[2,1],m1[2,2],     0,        0,           0, 0               \
      0    ,   0,       m2[1,1],m2[1,2],     0, 0               \
      0    ,   0,       m2[2,1],m2[2,2],     0,  0              \
      0    ,   0,             0,        0,      m3[1,1],m3[1,2] \
      0    ,   0,             0,        0,      m3[2,1],m3[2,2] )

That is, I seek to place each of the individual matrices along the diagonal, zeros elsewhere. In my problem, both the number of matrices and the dimensions of each matrix may be rather large.

Thanks in advance!

Matt Baker 
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index