IDL是一种交互式数据分析和可视化语言,具有广泛的科学和工程应用。
数值运算
; 加法
a = 5
b = 3
c = a + b
print, c ; 输出8
; 减法
a = 5
b = 3
c = a - b
print, c ; 输出2
; 乘法
a = 5
b = 3
c = a * b
print, c ; 输出15
; 除法
a = 5
b = 3
c = a / b
print, c ; 输出1.66667
逻辑运算
; 大于
a = 5
b = 3
c = (a > b)
print, c ; 输出1
; 小于
a = 5
b = 3
c = (a < b)
print, c ; 输出0
; 等于
a = 5
b = 3
c = (a == b)
print, c ; 输出0
; 不等于
a = 5
b = 3
c = (a != b)
print, c ; 输出1
; 逻辑与
a = 5
b = 3
c = (a > b) && (a < 10)
print, c ; 输出1
; 逻辑或
a = 5
b = 3
c = (a < b) || (a > 10)
print, c ; 输出0
字符串运算
; 字符串连接
a = "hello"
b = "world"
c = a + " " + b
print, c ; 输出hello world
; 字符串长度
a = "hello"
b = strlen(a)
print, b ; 输出5
; 字符串截取
a = "hello"
b = strmid(a, 2, 3)
print, b ; 输出ell
数组运算
; 数组加法
a = [1, 2, 3]
b = [4, 5, 6]
c = a + b
print, c ; 输出[5, 7, 9]
; 数组乘法
a = [1, 2, 3]
b = 2
c = a * b
print, c ; 输出[2, 4, 6]
; 数组平均值
a = [1, 2, 3]
b = mean(a)
print, b ; 输出2
以上是IDL基本运算的示例代码