Macro processor Error; follow up question on saving results

Dear all,

I have a question regarding the macro processor:
I have a nicely running model, now I want to check for gsy in 0:0.1:0.4 and tau in 0:0.15:0.6.
I set up a macro processor to do this but I get the following error:

ERROR in macro-processor: gexoutil.mod:173.16-17: @#for loop not matched by an @#endfor (unexpected end of file)

My Dynare version is 4.1.
Unfortunately I cannot find my mistake…

Further, once this problem is solved, I would like to store the variance of y for each iteration, i.e. 25 times, in a table which should have the following properties: 5x5 with tau on the vertical axis and gsy on the horizontal. How is there a nice and efficient way to do such a thing?

I guess I have to extract the results from oo_.var(1,1), but then how can I assign the correct cell to put it in the new matrix?

Thanks a lot for your advice.

Remove the semicolons after your endfors.

To store the output of oo_.var in a cell, do the following:

mycell=cell(5,5);
@#for ii in 1:5
    @# for jj in 1:5
            gsy = gsys(@{ii});
            tau = taus(@{jj});
            stoch_simul(order=1,irf=20) y;
            mycell{@{jj}, @{ii}} = oo_.var(1);
    @# endfor
@#endfor

I tested it with 4.3.3 (you should upgrade).

Dear Houtan,
Thank you very much, this is great help!!!
I will definitely upgrade the dynare version.
Best, philipp

Dear Houtan,

maybe you can help me out once more:
The thing is I have 4 different shocks in my model and I would like to stora a table as above for each of the shocks,
but Id prefer to have the code in one .mod file and not use a file for each shock. Do you know of a trick using the
macro processor on how to save the results for each shock? Im not sure how to loop over the shocks creating a mycell for each, and Id appreciate your help very much.

Best,
Philipp