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 on April 23, and its replacement, statalist.org is already up and running.


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

st:weave two matrices row by row


From   Amanda Fu <mandy.fu1@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st:weave two matrices row by row
Date   Sun, 26 Dec 2010 19:34:28 -0500

Hi All,

I was wondered if there is any way to weave two matrix row by row.
Say, I have matrix A [10,8] and B[10,8]. I want to create a new matrix
C looks like as:

matrix C [20,8]:
---------------------------------
row 1 :        row 1 of A
row 2:         row 1 of B
row 3:         row 2 of A
row 4:         row 2 of B
..........
row 19:      row 10 of A
row 20:      row 10 of B
---------------------------------
Right now I think I could do the following:

(1) matrix define C as a 20*8 matrix.
(2) use -mkmat- to change A and B into 8 variables respectively
A1,A2,..A8,B1,..,B8.
(3) Then define each row using the variables from (2).

But  when actually conducting the above way,I find it requires to be
very careful and  much more work than I expected. This is why I think
it would be better that I ask the expert here to see how an expert
will deal with this.

Thanks for your time!

Sincerely,
Amanda
*
*   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