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: matrix subscripting using loop
From
Scott Merryman <[email protected]>
To
[email protected]
Subject
Re: st: matrix subscripting using loop
Date
Wed, 15 Sep 2010 09:19:26 -0500
On Wed, Sep 15, 2010 at 8:27 AM, Maarten buis <[email protected]> wrote:
> --- On Wed, 15/9/10, Thomas wrote:
>> I would like to turn a 1 X 49 matrix
>> into a 7 X 7 matrix using a loop.
>
> Have you tried to use the rowshape()
> in Mata?
>
Here is one way to use a loop:
mata
a = (1..49)'
for (i=1; i<=7; i++) {
b[1::7,i] = a[7*i-6::7*i,1]
}
b
end
Scott
*
* 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/