Include file stored as string variable

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.

Include file stored as string variable

Postby ChrisZ » Mon Feb 23, 2015 12:55 pm

Hi,

when using Dynare 4.4.2, I usually split the model files in calibration, model equations, and others. Some of these files are not located in the same folder but in a subfolder or an other folder on the same directory level. I have already figured out that dynare can handle expressions as
Code: Select all
@#include "../model_specs/calibration.mod"
to get the file located somewhere else. However, I have a MATLAB path function running in background which returns the absolute path to the specific files. Is there any possibility to load the string variable returned from the path function e.g. xy directly with something like
Code: Select all
@#inlcude xy
?

Thanks in advance. Best,
Chris
ChrisZ
 
Posts: 1
Joined: Mon Feb 23, 2015 12:42 pm

Re: Include file stored as string variable

Postby HoutanBastani » Tue Feb 24, 2015 11:05 am

Not at the moment.

The macroprocessor does text expansion within the preprocessor and thus does not have direct access to the matlab workspace.

However, I say not at the moment, because it would be possible to add this functionality. In essence, you would pass the matlab variable of your choice at the dynare command line using the -D switch. At the current time, this does not work with the @#include macro command as it's expecting a quoted string. This could be changed, and I'll add it to our long to do list and it might just be done in the next version of dynare. It also might not. So, in the meanwhile, you'll have to hard code these strings.
Best,
Houtan
HoutanBastani
 
Posts: 197
Joined: Fri Jan 22, 2010 4:11 pm
Location: Paris, France

Re: Include file stored as string variable

Postby HoutanBastani » Tue Feb 24, 2015 1:56 pm

So this has just been fixed in unstable, and will be available in tomorrrow's snapshot package.

To summarize, you need to do something of the order of the following in Matlab:
Code: Select all
>> xy='/path/to/dir/with/other/modfile/';
>> dynare modfile.mod -Dpath=xy


and then, in your modfile, you'll have:
Code: Select all
@#define othermodfile=path+'othermodfile.mod'
@#include othermodfile
Best,
Houtan
HoutanBastani
 
Posts: 197
Joined: Fri Jan 22, 2010 4:11 pm
Location: Paris, France


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 10 guests