Macro language

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Macro language

Postby andwes » Tue Jun 29, 2010 8:33 am

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:

<START OF EXAMPE>

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;

<END OF EXAMPE>

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
andwes
 
Posts: 20
Joined: Wed Mar 17, 2010 2:17 pm

Re: Macro language

Postby andwes » Tue Jun 29, 2010 9:36 am

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

Andreas
andwes
 
Posts: 20
Joined: Wed Mar 17, 2010 2:17 pm


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 9 guests