1、变量定义
①将变量转换为合法变量
IDL> print,idl_validname('a bac',/convert_space)
a_bac
print,idl_validname('1.a bac',/convert_all)
_1_a_bac
②局部变量
pro test_1 ;print,'idl' a=10 end pro test_var test_1 print,a end
这个语句会报错
③全局变量
pro test_1 ;print,'idl' ;a=10 defsysv,'!var',10 end pro test_var test_1 ;print,a print,!var end
④公共区域
pro test_1 common comName,var1 var1=10 end pro test_var common comName test_1 print,var1 end
2、定义数组
arr=[[1,2,3,3],[1,1,1,1]]
help,arr
print,arr[3,0]
先列后行
①
IDL> arr=indgen(5) IDL> help,arr ARR INT = Array[5] IDL> print,arr 0 1 2 3 4 IDL> print,3*arr 0 3 6 9 12 IDL> print,3^arr 1 3 9 27 81
等差数列,等比数列
print,arr mod 2
②数组引用
IDL> a=indgen(8)*3 IDL> print,a 0 3 6 9 12 15 18 21 IDL> print,a[2:4] 6 9 12 IDL> idx=[3,5] IDL> print,a[idx] 9 15 IDL>
IDL> print,a 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 IDL> print,a[2:3,0:1] 2 3 6 7
IDL> print,a[1:3:2,*] 1 3 5 7 9 11 13 15 IDL> print,a>5 5 5 5 5 5 5 6 7 8 9 10 11 12 13 14 15 IDL>
Result = SIZE( Expression [, /L64] [, /DIMENSIONS | , /FILE_LUN | , /FILE_OFFSET | , /N_DIMENSIONS | , /N_ELEMENTS | , /SNAME, | , /STRUCTURE | , /TNAME | , /TYPE] )
IDL> a=indgen(5,6) IDL> print,a 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 IDL> idx=where(a gt 22) IDL> print,idx 23 24 25 26 27 28 29 IDL> print,a[idx] 23 24 25 26 27 28 29 IDL>