# Macro language

**URL:** <https://forum.dynare.org/t/macro-language/1525>\
**Category:** Dynare help (legacy posts)\
**Created:** [29 June 2010 08:33 UTC](https://forum.dynare.org/t/macro-language/1525 "2010-06-29T08:33:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andwes](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/b782af/32.png) [@andwes](https://forum.dynare.org/u/andwes)\
**Post date:** [29 June 2010 08:33 UTC](https://forum.dynare.org/t/macro-language/1525/1 "2010-06-29T08:33:35Z")

</div>

Hi,

I am trying to assign initial values in a proram using macro language loops. The initial values are specified in a standard vector. When trying to assing values to variables from the vector it doesn’t work; see the simple example below, where Xsol is the vector, chi\_@{i} a variable:

Xsol=[1 2 3 4 5 6 7 8 9];

@#define J = 9

@#for i in 1:(J-1)

```
var chi_@{i};

```

@#endfor

model;

@#for i in 1: J - 1  
chi\_@{i}=3;  
@#endfor

end;

initval;

@#for i in 1:J-1

```
chi_@{i} = Xsol(i);

```

@#endfor  
end;

The problem is that when trying to assign initial values, i get an error message

“??? Subscript indices must either be real positive integers or logicals.”

due to the Xsol(i) term when assigning initial values (if replace Xsol(i) by, say 2 it works). How should this be done? In my general program the Xsol vector is large and there are several variables of the chi\_@{i} type. Thus, it would be good if it is possible to use for loops when assingning initial values.

Andreas

---

<div class="post-metadata">

**Author:** ![andwes](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/b782af/32.png) [@andwes](https://forum.dynare.org/u/andwes)\
**Post date:** [29 June 2010 09:36 UTC](https://forum.dynare.org/t/macro-language/1525/2 "2010-06-29T09:36:35Z")

</div>

I figured out the answer: use Xsol(@{i}) instead of Xsol(i). Of course…

Andreas
