For example,
My files are naming after 00.dat, 01.dat, 02.dat..., each file contains multiple columns and I use READCOL
to read them into variables.
for i = 0, n-1 do begin
readcol, string(i, F='(I02)')+'.dat', F='D,D', a0, b0
readcol, string(i, F='(I02)')+'.dat', F='D,D', a1, b1
.
.
c1 = a1 / a0
c2 = a2 / a0
.
.
d1 = b1 / b0
d2 = b2 / b0
.
.
endfor
This works fine, but I cannot type all the varialbes one by one if there will be, say, one hundred variables.
Therefore, I want to use for loop to generate: a(i), b(i), c(i), d(i). In that sense, the code will look like:
for i = 0, n-1 do begin
readcol, string(i, F='(I02)')+'.dat',F='D,D', a(i), b(i)
endfor
for i = 0, n-1 do begin
c(i) = a(i) / a(0)
d(i) = b(i) / b(0)
endfor
But this doesn't work, is there any method to declare variables in a for loop and while doing math?
(I am not a native English speaker. Please let me know If there is anything unclear in my question. Thank you!)