I don't think MATLAB is the good software for learning programming at very beginning. It contains all kind of library and functions. Sometimes you don't need to know what did the MATLAB do for your script, and sometimes you just use the MATLAB as a calculator, not a programming software.
What's your specific question? Did you mean the output name or big size data generate?
If you mean the output name :
program main
implicit none
integer i
real vars
character(len=255) output_name
do i=1,1000
write(output_name,100) i,"dat"
write(10,file=trim(output_name)) vars...