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: Using loop in Mata?
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Using loop in Mata?
Date
Tue, 9 Jul 2013 10:44:11 +0100
For the spellings "Stata" and "Mata" see
http://www.stata.com/support/faqs/resources/statalist-faq/#spell
Depending on the initial shapes of your matrices, you might be able to
do the restructuring some other way. Otherwise I can only point
vaguely in the direction of pointers.
Nick
[email protected]
On 9 July 2013 09:11, Henk-Wim de Boer <[email protected]> wrote:
> Hello everyone,
>
>
> I am using Mata and I want to put the following code into a loop:
>
> U_1 = colshape(U_1,6)
> U_2 = colshape(U_2,6)
> U_3 = colshape(U_3,6)
> U_4 = colshape(U_4,6)
> U_5 = colshape(U_5,6)
> U_6 = colshape(U_6,6)
> U_7 = colshape(U_7,6)
> U_8 = colshape(U_8,6)
> U_9 = colshape(U_9,6)
> U_10 = colshape(U_10,6)
>
>
> In STATA, I would use a local variable:
>
> forvalues r=1(1)10 {
> gen U_`r' = ....
> }
>
> Obviously, this does not work in MATA. Does anyone know how to code this in a proper way in MATA?
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/