Page 1 of 1

Saving reports of multiple simulations to different files

PostPosted: Tue Feb 25, 2014 12:21 pm
by mikelaughton
Hi,

I'm running a basic OLG model and want to report the results implied by different values of rho. I tried handling this with a macro-processor loop but I kept getting errors about too many equations for variables. So I did it instead with an Octave loop and the simulations run absolutely fine as they're supposed to.

However, I tried to do something like this:
Code: Select all
for i = 1:4
...
f = ["reports" i ".txt"];
dynatype(f);


And all that happens is that Dynatype saves to a file called "f".

I'd be really grateful if anybody could explain what I'm doing wrong.

Best,
Mike

Re: Saving reports of multiple simulations to different file

PostPosted: Tue Feb 25, 2014 12:49 pm
by jpfeifer
Shouldn't it be
Code: Select all
f = ['reports',num2str(i),'.txt'];

Re: Saving reports of multiple simulations to different file

PostPosted: Tue Feb 25, 2014 2:55 pm
by mikelaughton
Hi, thanks for the response.

The num2str bit is right (I forgot that!) but the file that the simulations save to is still just called "f" (i.e., not what f signifies).

So what happens is that a file called f is created and is overwritten with each simulation. Just need to get dynasave to accept a variable name, if that's possible.

Thanks again

Re: Saving reports of multiple simulations to different file

PostPosted: Wed Feb 26, 2014 10:56 am
by jpfeifer
Try wrapping it into an eval-command:
Code: Select all
eval(['dynatype(''reports',num2str(i),'.txt'')'])

Re: Saving reports of multiple simulations to different file

PostPosted: Wed Mar 05, 2014 3:17 pm
by mikelaughton
Thanks so much!