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, is already up and running.

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

st: RE: [Mata] naming matrices in a loop

From   "Nick Cox" <>
To   <>
Subject   st: RE: [Mata] naming matrices in a loop
Date   Thu, 18 Mar 2010 15:33:06 -0000

In a word, pointers. 

Another answer: Although experience in Stata can lead you to want to
program in this way, I often find that the problem can be structured to
avoid it. 


Antoine Terracol

There must be an obvious way to solve my problem, but I just seem to be 
unable to find it...

In a Mata loop, I want to store the result of each pass into a separate 
matrix whose name depends on the value of the counter

It would look like:

for (n=1;n<=10;n++){
		name_that_depends_on_n=<result of the calculation>

so that I get 10 matrices named, for example, result1, result2, ..., 

In Stata, I would do something like

forvalues i=1/10 {
		result`i'=<result of the calculation>


How can this be done in Mata?

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index