Hi Everyone,
I've been having some trouble using a for loop to perform tasks over
similarly named vectors. This simple example below illustrates my problem
pretty well. I would like to create two 5x5 arrays of zeros, but with
dynamic names. In this case x_foo and x_bar would be the names. When I run
this code, it clearly is looping over the string set, but it is not
actually creating the array. I have had similar problem trying to call
arrays into functions dynamically based on their names. Clearly I am just
incorrectly referencing i, but I cannot figure it where the error is. I am
trying to port a complicated version of this code from Stata, where this is
quite easy to do by referencing i in your code as `i'. Sorry for such a
novice question, but this has been driving me nuts all day!
Thanks in advance!
Alex
n=5
for i in ["foo","bar"]
x_$i=zeros(n,n)
println("x_$i")
end
x_bar