Search code examples
idl-programming-language

Interactive Data Language - Array manipulation


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?


Solution

  • 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