Matrix subscripts are typed in brackets. For example
mata
A = (1,2,3\4,5,6)
C = J(2,3,.)
for (i=1; i<=2; i++) {
C[i,.] = A[i,.]
C[i,.] // display
}
end
Please see
. help m2_subscripts
ben
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of
> adiallo5@worldbank.org
> Sent: Monday, November 28, 2005 7:52 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Re: A Mata question.
>
>
> Thanks Nick for the answer.
> My other question is how to create
> new matrix within loops?
> I am puzzled by the fact that there is no `i'
> in mata's loops as in normal stata.
> Best regards.
> Amadou.
>
> mata:
> A1 = (1,2,3\4,5,6)
> A1
> A2 = (1,2,3\4,5,6)
> A2
> B1=A1
> B1
> B2=A2
> B2
> for (i=1;i<=2;i++) {
> i // just to display the increment
> C(i) = A(i) // ??? I tried Ci = Ai and C`i' = A`i' plus
> various variants (==,
> (), etc...) with no success
> C(i) // display
> }
> end:
>
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/