Page 1 of 1

How to edit the mod file via m file in MatLab?

PostPosted: Fri Dec 11, 2015 1:46 am
by fuyangzhao
Hi everyone:

I'm trying to write a loop in which I can see how the results change with different parameterization. Is there any possibility that I edit the mod file via m file in MatLab in order to change the value of a particular parameter in a loop?

Thanks!

Re: How to edit the mod file via m file in MatLab?

PostPosted: Fri Dec 11, 2015 7:44 am
by jpfeifer

Re: How to edit the mod file via m file in MatLab?

PostPosted: Fri Dec 11, 2015 12:17 pm
by fuyangzhao

Thanks! I read the link you gave me. And I wrote the following code in a MatLab m file:
Code: Select all
etas = 0.5:0.01:1.5;

for numb=1:101
    set_param_value('eta',etas(numb));
    dynare lwz_model.mod;
   
end

And it reports the following
Attempt to reference field of non-structure array.

Error in set_param_value (line 22)
i = strmatch(pname,M_.param_names,'exact');


Can you help me?

Re: How to edit the mod file via m file in MatLab?

PostPosted: Thu Dec 17, 2015 9:34 am
by jpfeifer
You are supposed to run Dynare once before the loop to initialize everything. Only then you can reset the parameter and call the required functions of Dynare. Please follow the example in the linked post closely, otherwise it will not work.