I have two arrays of the same length in IDL. I want to combine the two arrays pairwise so that I can then print the two arrays as columns to file. Is this possible?
Asked
Active
Viewed 196 times
1 Answers
1
You can combine two arrays (with same length n) like this :
combined = [[array1], [array2]]
so that combined
is n x 2.
Although you can write your data without creating a third array:
openw, lun, 'path_to_file.ext', /get_lun
foreach elem, array1, index do begin
printf, lun, elem, array2[index]
endforeach
free_lun, lun

Ludic
- 26
- 1
- 3
-
I managed to solve the problem doing something like you suggest yesterday. Thanks for the answer anyhow. – stars83clouds Dec 10 '13 at 22:59
-
2The use of `foreach` assumes >= IDL 8.0. – sappjw Dec 11 '13 at 15:02