Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Mata looping question


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Mata looping question
Date   Tue, 18 Oct 2011 11:54:36 +0200

On Tue, Oct 18, 2011 at 11:37 AM, Anna Reimondos wrote:
> For example if I have one original matrix called 'a'
>
> matrix a=(1,0,0\0,2,1\0,1,0\0,0,0)
> matrix list a
>
> I then want to create another matrix 'b' which is equal to 'a' but
> where every element has been shifted up one row and across one column.

I would not do that with a loop:

*------------- begin example ----------------
mata
a=(1,0,0\0,2,1\0,1,0\0,0,0)
b = J(5,1,0), (a \ J(1,3,0))
b
end
*----------- end example ----------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index