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
endpro test_var
test_1
print,a
end
這個語句會報錯
③全域性變數
pro test_1;print,'idl'
;a=10
defsysv,'!var',10
endpro test_var
test_1
;print,a
print,!var
end
④公共區域
pro test_1common comname,var1
var1=10
endpro 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)*3idl> 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,a0 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>
IDL 使用陣列
1.下標方式 idl array indgen 8 idl print,array 0 1 2 3 4 5 6 7idl print,array 3 idl array indgen 8 idl print,array 1 7idl print,array 5 1 3 4 5 6 7 2.向量方式 ...
指標變數和陣列
int arr 2 int arr int i arr 0 arr 1 23 char str abc 字元內容儲存在堆上 char str1 字元內容儲存在棧上第一種情況 字元內容會儲存在堆上,並在棧裡儲存str指標變數,變數值為字元在堆上的首位址。第二種情況 字元內容會儲存在棧上,但是不會有額外...
IDL 陣列運算
1.求大 求小和求餘 idl arr indgen 4 idl print,arr 0 1 2 3idl print,arr 3 3 3 3 3idl print,arr 2 0 1 2 2idl print,arr mod 2 0 1 0 1 2.陣列與數運算 idl 陣列加數 idl arr1 ...