Tuesday, March 18, 2014

Fortran and Octave/Matlab: Variable File Names

Suppose you want to write to files with names that are not known before compile time, or loop over a set of related filenames. For example, you may want to write to files file0001.txt, file0002.txt, ... so on.

Doing this in Octave/Matlab is quite easy: For example:
In Fortran 90, you do something similar

It is easy to extend this idea to create files using loops.

No comments: