# Inputting shocks through a loop

Dear all

Is there a way to read in the shock_files in a loop, because I want to do some simulations where I read in the shocks from 1000 different files. I’ve tried using the eval function with a for loop, but this doesn’t seem to work, I think because there is an equals sign in there:
Example:

for i=1:10
first=‘shocks’;
second=’(shocks_file=shocks’,int2str(i)] ;
third=’)’ ;
eval([first,second,third] );
//shocks(shocks_file=shocks2);
var eps;
periods 1;
values 0;
end;
simul(periods=40);
format long
end;

Another way I was thinking it might to be able to be done is that if I have one matrix with all shocks in it, can I set for example:

var eps=shock(1,1)

to set eps as the first element of the shock matrix?

I think whenever dynare starts running it clears the workspace so I haven’t been able to do it this way. Is there a way of stopping it clearing the workspace?

Thank you
Mai