Dealing with variables created in MatLab

Hi,

Once I execute the dynare(‘MyModel’) command, it appears that Dynare clears all variables I have created in MatLab before. Is there a possibility to use variables created in previous MatLab functions within the .mod file?

I’m thinking about something like:

simulationperiods = 20;
forecasthorizon = 1;
dynare(‘MyModel’, simulationperiods, forecasthorizon);

It turns out that the variable simulationperiods or forecasthorizon are cleared after having run dynare. Moreover, I can take the variables as input for dynare but they will be cleared in turn and cannot be used for model calculations. Is there a possibility to deal with variables created in MatLab? THX in advance!

Hi,

You just have to define the matlab variables in the mod file. If you don’t want to use matlab statements in the mod file, you can use the noclearall keyword (I don’t know if this is documented somewhere). In you example, you would have :

    simulationperiods = 20;
    forecasthorizon = 1;
    dynare MyModel noclearall

Best,
Stéphane.