1.下标方式
IDL> array=indgen(8) IDL> print,array 0 1 2 3 4 5 6 7 IDL> print,array[3]
IDL> array=indgen(8) IDL> print,array[-1] 7 IDL> print,array[-5:-1] 3 4 5 6 7
2.向量方式
IDL> ;读取数组中第一,二,四和第六个元素的代码 IDL> array=indgen(8) IDL> indices=[0,1,3,5] IDL> print,array[indices] 0 1 3 5
IDL> ;对30行20列的索引数组取出第6~10列中第12~15行的数据 IDL> array=Indgen(20,30) IDL> subarray=array[5:9,11:14] IDL> help,subarray SUBARRAY INT = Array[5, 4]
IDL> ;提取第10行的值 IDL> vectoer=array[*,9] IDL> help,vector VECTOR UNDEFINED = <Undefined>
IDL> ;提取对角线元素 IDL> arr=indgen(5,5) IDL> print,arr[indgen(5),indgen(5)] 0 6 12 18 24 IDL> print,arr[indgen(5)*(5+1)] 0 6 12 18 24 IDL> print,arr[0:(5*5-1):(5+1)] 0 6 12 18 24